From 1722559d24142d05731b9fac79e585db7e1bb02d Mon Sep 17 00:00:00 2001 From: Kevin Casey Date: Mon, 24 Mar 2014 22:52:43 -0700 Subject: [PATCH] Continue to use the bind parameter syntax even on non prepared statements Appears to effectively revert #8966 He was using the non prepared statement so that .to_sql would return sql with parameters already bound, although this doesn't relate to whether we are using prepared statements or not. Also related https://github.com/rails/rails/commit/fd398475 --- .../connection_adapters/postgresql_adapter.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index bcad9f30d78fb..2e235c8422077 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -847,8 +847,15 @@ def initialize_type_map(type_map) FEATURE_NOT_SUPPORTED = "0A000" #:nodoc: + def unprepared_visitor + Arel::Visitors::PostgreSQL.new self + end + def exec_no_cache(sql, name, binds) - log(sql, name, binds) { @connection.async_exec(sql) } + type_casted_binds = binds.map { |col, val| + [col, type_cast(val, col)] + } + log(sql, name, binds) { @connection.async_exec(sql, type_casted_binds.map { |_, val| val }) } end def exec_cache(sql, name, binds)