Skip to content

Commit

Permalink
Merge pull request #24958 from maclover7/fix-24955
Browse files Browse the repository at this point in the history
Fix ActiveRecord::LogSubscriber edge case
  • Loading branch information
rafaelfranca committed May 21, 2016
2 parents e3b239c + c650341 commit 3e54c1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion activerecord/lib/active_record/log_subscriber.rb
Expand Up @@ -22,7 +22,11 @@ def initialize

def render_bind(attribute)
value = if attribute.type.binary? && attribute.value
"<#{attribute.value.bytesize} bytes of binary data>"
if attribute.value.is_a?(Hash)
"<#{attribute.value_for_database.to_s.bytesize} bytes of binary data>"
else
"<#{attribute.value.bytesize} bytes of binary data>"
end
else
attribute.value_for_database
end
Expand Down
6 changes: 6 additions & 0 deletions activerecord/test/cases/log_subscriber_test.rb
Expand Up @@ -215,5 +215,11 @@ def test_binary_data_is_not_logged
wait
assert_match(/<16 bytes of binary data>/, @logger.logged(:debug).join)
end

def test_binary_data_hash
Binary.create(data: { a: 1 })
wait
assert_match(/<7 bytes of binary data>/, @logger.logged(:debug).join)
end
end
end

0 comments on commit 3e54c1c

Please sign in to comment.