Skip to content

Commit

Permalink
Ensure PG connection is configured before looking up types
Browse files Browse the repository at this point in the history
Fix: rails#49439

Because Postgres adapter types are connection dependent,
we can't lookup types without first connecting to the database.

Note, this really isn't good, ideally types should be stored in the
schema cache so that we don't have to extract types every time.
  • Loading branch information
byroot committed Oct 2, 2023
1 parent 8340f8f commit 4b5927a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def type_cast(value) # :nodoc:
end

def lookup_cast_type_from_column(column) # :nodoc:
verify! if type_map.nil?
type_map.lookup(column.oid, column.fmod, column.sql_type)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,7 @@ def initialize_type_map(m) # :nodoc:
end

private
def type_map
@type_map ||= Type::HashLookupTypeMap.new
end
attr_reader :type_map

def initialize_type_map(m = type_map)
self.class.initialize_type_map(m)
Expand Down

0 comments on commit 4b5927a

Please sign in to comment.