diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-03-26 17:40:36 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-03-26 17:41:47 -0600 |
commit | cd09261846053bb40f8c859b8644b28208b6d7b9 (patch) | |
tree | fac9abae08696d097401c7703c474305a1e23215 /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | |
parent | 3b50a7a3e18e1ae5ea1d76927e37021f50389abc (diff) | |
parent | 647eb2cf1cd65b0391e3584361f0fc76246e64f3 (diff) | |
download | rails-cd09261846053bb40f8c859b8644b28208b6d7b9.tar.gz rails-cd09261846053bb40f8c859b8644b28208b6d7b9.tar.bz2 rails-cd09261846053bb40f8c859b8644b28208b6d7b9.zip |
Partially merge #17650
Merges 647eb2cf1cd65b0391e3584361f0fc76246e64f3. The pull request as a
whole is quite large, and I'm reviewing the smaller pieces individually.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 37bf4d77f8..e616cee5eb 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -1,3 +1,7 @@ +# Make sure we're using pg high enough for type casts and Ruby 2.2+ compatibility +gem 'pg', '~> 0.18' +require 'pg' + require "active_record/connection_adapters/abstract_adapter" require "active_record/connection_adapters/postgresql/column" require "active_record/connection_adapters/postgresql/database_statements" @@ -12,10 +16,6 @@ require "active_record/connection_adapters/statement_pool" require 'arel/visitors/bind_visitor' -# Make sure we're using pg high enough for Ruby 2.2+ compatibility -gem 'pg', '~> 0.18' -require 'pg' - require 'ipaddr' module ActiveRecord @@ -278,6 +278,7 @@ module ActiveRecord @table_alias_length = nil connect + add_pg_encoders @statements = StatementPool.new @connection, self.class.type_cast_config_to_integer(config.fetch(:statement_limit) { 1000 }) @@ -803,6 +804,15 @@ module ActiveRecord end end + def add_pg_encoders + map = PG::TypeMapByClass.new + map[Integer] = PG::TextEncoder::Integer.new + map[TrueClass] = PG::TextEncoder::Boolean.new + map[FalseClass] = PG::TextEncoder::Boolean.new + map[Float] = PG::TextEncoder::Float.new + @connection.type_map_for_queries = map + end + def add_pg_decoders coders_by_name = { 'int2' => PG::TextDecoder::Integer, |