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)