diff options
author | Lars Kanis <lars@greiz-reinsdorf.de> | 2015-03-21 21:51:55 +0100 |
---|---|---|
committer | Lars Kanis <lars@greiz-reinsdorf.de> | 2015-03-25 15:05:23 +0100 |
commit | 1d8d5a74b81b8aab1f5e6d233d509a92525ed4e1 (patch) | |
tree | 6310199303f48857333d34b16041e0c424c5d5b6 /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | |
parent | 348377da4d623a81b570b2bf46e6ef9e5ee4e12f (diff) | |
download | rails-1d8d5a74b81b8aab1f5e6d233d509a92525ed4e1.tar.gz rails-1d8d5a74b81b8aab1f5e6d233d509a92525ed4e1.tar.bz2 rails-1d8d5a74b81b8aab1f5e6d233d509a92525ed4e1.zip |
PostgreSQL, Fix OID based type casts in C for primitive types.
The type map was introduced in aafee23, but wasn't properly filled.
This mainly adjusts many locations, that expected strings instead of
integers or boolean.
add_pg_decoders is moved after setup of the StatementPool, because
execute_and_clear could potentially make use of it.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 96a3ac7c31..37bf4d77f8 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -278,8 +278,6 @@ module ActiveRecord @table_alias_length = nil connect - add_pg_decoders - @statements = StatementPool.new @connection, self.class.type_cast_config_to_integer(config.fetch(:statement_limit) { 1000 }) @@ -287,6 +285,8 @@ module ActiveRecord raise "Your version of PostgreSQL (#{postgresql_version}) is too old, please upgrade!" end + add_pg_decoders + @type_map = Type::HashLookupTypeMap.new initialize_type_map(type_map) @local_tz = execute('SHOW TIME ZONE', 'SCHEMA').first["TimeZone"] @@ -798,7 +798,7 @@ module ActiveRecord ) end_sql execute_and_clear(sql, "SCHEMA", []) do |result| - result.getvalue(0, 0) == 't' + result.getvalue(0, 0) end end end @@ -814,12 +814,12 @@ module ActiveRecord 'bool' => PG::TextDecoder::Boolean, } query = <<-SQL - SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, t.typtype, t.typbasetype + SELECT t.oid, t.typname FROM pg_type as t SQL coders = execute_and_clear(query, "SCHEMA", []) do |result| result - .map { |row| construct_coder(row, coders_by_name['typname']) } + .map { |row| construct_coder(row, coders_by_name[row['typname']]) } .compact end @@ -830,7 +830,7 @@ module ActiveRecord def construct_coder(row, coder_class) return unless coder_class - coder_class.new(oid: row['oid'], name: row['typname']) + coder_class.new(oid: row['oid'].to_i, name: row['typname']) end ActiveRecord::Type.add_modifier({ array: true }, OID::Array, adapter: :postgresql) |