{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/19871","labels_url":"https://api.github.com/repos/rails/rails/issues/19871/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/19871/comments","events_url":"https://api.github.com/repos/rails/rails/issues/19871/events","html_url":"https://github.com/rails/rails/issues/19871","id":70350694,"number":19871,"title":"ActiveRecord logger bug for binary column","user":{"login":"pienkowskip","id":4947579,"avatar_url":"https://avatars.githubusercontent.com/u/4947579?v=3","gravatar_id":"","url":"https://api.github.com/users/pienkowskip","html_url":"https://github.com/pienkowskip","followers_url":"https://api.github.com/users/pienkowskip/followers","following_url":"https://api.github.com/users/pienkowskip/following{/other_user}","gists_url":"https://api.github.com/users/pienkowskip/gists{/gist_id}","starred_url":"https://api.github.com/users/pienkowskip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pienkowskip/subscriptions","organizations_url":"https://api.github.com/users/pienkowskip/orgs","repos_url":"https://api.github.com/users/pienkowskip/repos","events_url":"https://api.github.com/users/pienkowskip/events{/privacy}","received_events_url":"https://api.github.com/users/pienkowskip/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-23T08:55:10Z","updated_at":"2015-04-23T12:25:46Z","closed_at":"2015-04-23T12:25:46Z","body":"I found out there is a problem with logging update operation when record binary field is set to `nil`. Here goes simple script which illustrates the problem:\r\n\r\n```ruby\r\n#!/usr/bin/env ruby\r\n\r\nrequire 'active_record'\r\n\r\nputs \"Active Record #{ActiveRecord::VERSION::STRING}\"\r\n\r\nActiveRecord::Base.establish_connection(\r\n    :adapter  => 'sqlite3',\r\n    :database => ':memory:'\r\n)\r\n\r\nActiveRecord::Schema.define do\r\n    create_table :variables, :force => true do |t|\r\n        t.binary :value\r\n    end\r\nend\r\n\r\nclass Variable < ActiveRecord::Base\r\nend\r\n\r\nActiveRecord::Base.logger = Logger.new(STDOUT)\r\n\r\nvar = Variable.new\r\nvar.value = 'abc'\r\nvar.save!\r\nvar.value = nil\r\nvar.save!\r\n```\r\n\r\nDuring the second `save!` I get such error instead of proper log message:\r\n`E, [2015-04-23T10:48:53.992962 #14127] ERROR -- : Could not log \"sql.active_record\" event. NoMethodError: undefined method 'bytesize' for nil:NilClass [...`\r\n\r\nThe record is properly updated - this is a problem with logger.\r\n\r\nMy ActiveRecord version is 4.1.0."},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/95568166","html_url":"https://github.com/rails/rails/issues/19871#issuecomment-95568166","issue_url":"https://api.github.com/repos/rails/rails/issues/19871","id":95568166,"user":{"login":"pienkowskip","id":4947579,"avatar_url":"https://avatars.githubusercontent.com/u/4947579?v=3","gravatar_id":"","url":"https://api.github.com/users/pienkowskip","html_url":"https://github.com/pienkowskip","followers_url":"https://api.github.com/users/pienkowskip/followers","following_url":"https://api.github.com/users/pienkowskip/following{/other_user}","gists_url":"https://api.github.com/users/pienkowskip/gists{/gist_id}","starred_url":"https://api.github.com/users/pienkowskip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pienkowskip/subscriptions","organizations_url":"https://api.github.com/users/pienkowskip/orgs","repos_url":"https://api.github.com/users/pienkowskip/repos","events_url":"https://api.github.com/users/pienkowskip/events{/privacy}","received_events_url":"https://api.github.com/users/pienkowskip/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T12:25:46Z","updated_at":"2015-04-23T12:25:46Z","body":"Thanks! You are right."}}