diff options
author | Xavier Noria <fxn@hashref.com> | 2016-07-19 08:56:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-19 08:56:15 +0200 |
commit | b770f3c474b27e9dbd9d0cb55110d49f6bf114ed (patch) | |
tree | bb92d1aab05517e09c11d767cc96ef082b4102cc /activerecord/test/cases | |
parent | c02f3ea5e31677e7953abee5a1a2d5398d85ad47 (diff) | |
parent | f814585bb269f1dd2c275d6ae95d94d8e91d8061 (diff) | |
download | rails-b770f3c474b27e9dbd9d0cb55110d49f6bf114ed.tar.gz rails-b770f3c474b27e9dbd9d0cb55110d49f6bf114ed.tar.bz2 rails-b770f3c474b27e9dbd9d0cb55110d49f6bf114ed.zip |
Merge pull request #25886 from kamipo/pass_type_casted_binds_to_log_subscriber
Pass `type_casted_binds` to log subscriber for logging bind values properly
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/bind_parameter_test.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/cases/bind_parameter_test.rb b/activerecord/test/cases/bind_parameter_test.rb index fa924fe4cb..3f01885489 100644 --- a/activerecord/test/cases/bind_parameter_test.rb +++ b/activerecord/test/cases/bind_parameter_test.rb @@ -57,10 +57,13 @@ module ActiveRecord end def test_logs_bind_vars_after_type_cast + binds = [Relation::QueryAttribute.new("id", "10", Type::Integer.new)] + type_casted_binds = binds.map { |attr| type_cast(attr.value_for_database) } payload = { :name => 'SQL', :sql => 'select * from topics where id = ?', - :binds => [Relation::QueryAttribute.new("id", "10", Type::Integer.new)] + :binds => binds, + :type_casted_binds => type_casted_binds } event = ActiveSupport::Notifications::Event.new( 'foo', @@ -84,6 +87,12 @@ module ActiveRecord logger.sql event assert_match([[@pk.name, 10]].inspect, logger.debugs.first) end + + private + + def type_cast(value) + ActiveRecord::Base.connection.type_cast(value) + end end end end |