diff options
author | Lars Kanis <lars@greiz-reinsdorf.de> | 2018-05-27 12:53:47 +0200 |
---|---|---|
committer | Lars Kanis <lars@greiz-reinsdorf.de> | 2018-05-27 12:53:47 +0200 |
commit | 8d5c71ee7f3baf0f05d05d62bbc16ce13bc4679e (patch) | |
tree | 392698bcb261b2dce840e424b3bf0745b7fb1da4 | |
parent | 6349ad300f2cace625b1c733410c4a39c91028ec (diff) | |
download | rails-8d5c71ee7f3baf0f05d05d62bbc16ce13bc4679e.tar.gz rails-8d5c71ee7f3baf0f05d05d62bbc16ce13bc4679e.tar.bz2 rails-8d5c71ee7f3baf0f05d05d62bbc16ce13bc4679e.zip |
PostgreSQL: Prepare for pg-1.1.0
Version 1.1.0 deprecates exec and async_exec with a params array due to
distinct semantics between calls with and without params array.
Instead exec_params or async_exec_params shall be used.
Moreover in pg-1.1.0 exec_* and prepare methods are aliases for async_exec_*
and async_prepare. async_* methods don't need to be called explicit -
they are the default now, when calling exec_* and prepare.
For pg versions before 1.1, keep using async_exec.
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index fdf6f75108..57921cee26 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -4,6 +4,14 @@ gem "pg", ">= 0.18", "< 2.0" require "pg" +# Use async_exec instead of exec_params on pg versions before 1.1 +class ::PG::Connection + unless self.public_method_defined?(:async_exec_params) + remove_method :exec_params + alias exec_params async_exec + end +end + require "active_record/connection_adapters/abstract_adapter" require "active_record/connection_adapters/statement_pool" require "active_record/connection_adapters/postgresql/column" @@ -600,7 +608,7 @@ module ActiveRecord type_casted_binds = type_casted_binds(binds) log(sql, name, binds, type_casted_binds) do ActiveSupport::Dependencies.interlock.permit_concurrent_loads do - @connection.async_exec(sql, type_casted_binds) + @connection.exec_params(sql, type_casted_binds) end end end |