aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-12-05 14:48:11 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2013-12-05 14:49:01 -0800
commitdbdbda9a4a5cb9cd22e7a5a5625caa84edae6d5d (patch)
treeb989762784356a59e3d46847eb924d484f849458
parentfd5f3618bad1615bb8fc32b9c5ce69322e53c4e1 (diff)
downloadrails-dbdbda9a4a5cb9cd22e7a5a5625caa84edae6d5d.tar.gz
rails-dbdbda9a4a5cb9cd22e7a5a5625caa84edae6d5d.tar.bz2
rails-dbdbda9a4a5cb9cd22e7a5a5625caa84edae6d5d.zip
fix pg warnings on geometric types
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb33
1 files changed, 23 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 1ec1490263..d23a24589c 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -748,6 +748,25 @@ module ActiveRecord
initialize_type_map(type_map)
end
+ def add_oid(row, records_by_oid, type_map)
+ return type_map if type_map.key? row['type_elem'].to_i
+
+ if OID.registered_type? row['typname']
+ # this composite type is explicitly registered
+ vector = OID::NAMES[row['typname']]
+ else
+ # use the default for composite types
+ unless type_map.key? row['typelem'].to_i
+ add_oid records_by_oid[row['typelem']], records_by_oid, type_map
+ end
+
+ vector = OID::Vector.new row['typdelim'], type_map[row['typelem'].to_i]
+ end
+
+ type_map[row['oid'].to_i] = vector
+ type_map
+ end
+
def initialize_type_map(type_map)
result = execute('SELECT oid, typname, typelem, typdelim, typinput FROM pg_type', 'SCHEMA')
leaves, nodes = result.partition { |row| row['typelem'] == '0' }
@@ -757,19 +776,13 @@ module ActiveRecord
type_map[row['oid'].to_i] = OID::NAMES[row['typname']]
end
+ records_by_oid = result.group_by { |row| row['oid'] }
+
arrays, nodes = nodes.partition { |row| row['typinput'] == 'array_in' }
# populate composite types
- nodes.find_all { |row| type_map.key? row['typelem'].to_i }.each do |row|
- if OID.registered_type? row['typname']
- # this composite type is explicitly registered
- vector = OID::NAMES[row['typname']]
- else
- # use the default for composite types
- vector = OID::Vector.new row['typdelim'], type_map[row['typelem'].to_i]
- end
-
- type_map[row['oid'].to_i] = vector
+ nodes.each do |row|
+ add_oid row, records_by_oid, type_map
end
# populate array types