diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-07-19 10:20:58 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-07-19 14:11:58 +0900 |
commit | f814585bb269f1dd2c275d6ae95d94d8e91d8061 (patch) | |
tree | 0283addf37e75bac629533efbbfaeba9dceb7bdf /activerecord/test | |
parent | 5a302bf553af0e6fedfc63299fc5cd6e79599ef3 (diff) | |
download | rails-f814585bb269f1dd2c275d6ae95d94d8e91d8061.tar.gz rails-f814585bb269f1dd2c275d6ae95d94d8e91d8061.tar.bz2 rails-f814585bb269f1dd2c275d6ae95d94d8e91d8061.zip |
Pass `type_casted_binds` to log subscriber for logging bind values properly
Address to https://github.com/rails/rails/commit/5a302bf553af0e6fedfc63299fc5cd6e79599ef3#commitcomment-18288388.
Diffstat (limited to 'activerecord/test')
-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 |