diff options
author | Jon Moss <me@jonathanmoss.me> | 2016-05-10 15:42:07 -0400 |
---|---|---|
committer | Jon Moss <me@jonathanmoss.me> | 2016-05-10 15:42:07 -0400 |
commit | c650341573243307fbe6f63702a9a4e4e289cfcd (patch) | |
tree | 837f034952378269f05f9cf93f05f0a17e4632dc /activerecord/lib/active_record/statement_cache.rb | |
parent | 932655a4ef61083da98724bb612d00f89e153c46 (diff) | |
download | rails-c650341573243307fbe6f63702a9a4e4e289cfcd.tar.gz rails-c650341573243307fbe6f63702a9a4e4e289cfcd.tar.bz2 rails-c650341573243307fbe6f63702a9a4e4e289cfcd.zip |
Fix ActiveRecord::LogSubscriber edge case
If an attribute was of the binary type, and also was a Hash, it would
previously not be logged, and instead raise an error saying that
`bytesize` was not defined for the `attribute.value` (a `Hash`).
Now, as is done on 4-2-stable, the attribute's database value is
`bytesize`d, and then logged out to the terminal.
Reproduction script:
```ruby
require 'active_record'
require 'minitest/autorun'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.binary :preferences
end
end
class Post < ActiveRecord::Base
serialize :preferences
end
class BugTest < Minitest::Test
def test_24955
Post.create!(preferences: {a: 1})
assert_equal 1, Post.count
end
end
```
Diffstat (limited to 'activerecord/lib/active_record/statement_cache.rb')
0 files changed, 0 insertions, 0 deletions