Skip to content

Commit 618db13

Browse files
committed
Ensure PG connection is configured before looking up types
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.
1 parent 7c303b9 commit 618db13

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def type_cast(value) # :nodoc:
149149
end
150150

151151
def lookup_cast_type_from_column(column) # :nodoc:
152+
verify! if type_map.nil?
152153
type_map.lookup(column.oid, column.fmod, column.sql_type)
153154
end
154155

activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,9 +722,7 @@ def initialize_type_map(m) # :nodoc:
722722
end
723723

724724
private
725-
def type_map
726-
@type_map ||= Type::HashLookupTypeMap.new
727-
end
725+
attr_reader :type_map
728726

729727
def initialize_type_map(m = type_map)
730728
self.class.initialize_type_map(m)

0 commit comments

Comments
 (0)