{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/26024","repository_url":"https://api.github.com/repos/rails/rails","labels_url":"https://api.github.com/repos/rails/rails/issues/26024/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/26024/comments","events_url":"https://api.github.com/repos/rails/rails/issues/26024/events","html_url":"https://github.com/rails/rails/issues/26024","id":168864872,"number":26024,"title":"Optimistic locking does not work well with null in the database","user":{"login":"vsizov","id":417636,"avatar_url":"https://avatars.githubusercontent.com/u/417636?v=3","gravatar_id":"","url":"https://api.github.com/users/vsizov","html_url":"https://github.com/vsizov","followers_url":"https://api.github.com/users/vsizov/followers","following_url":"https://api.github.com/users/vsizov/following{/other_user}","gists_url":"https://api.github.com/users/vsizov/gists{/gist_id}","starred_url":"https://api.github.com/users/vsizov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsizov/subscriptions","organizations_url":"https://api.github.com/users/vsizov/orgs","repos_url":"https://api.github.com/users/vsizov/repos","events_url":"https://api.github.com/users/vsizov/events{/privacy}","received_events_url":"https://api.github.com/users/vsizov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails/rails/labels/activerecord","name":"activerecord","color":"0b02e1"},{"url":"https://api.github.com/repos/rails/rails/labels/attached%20PR","name":"attached PR","color":"006b75"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-02T11:41:41Z","updated_at":"2016-10-21T20:07:31Z","closed_at":null,"body":"I can't edit a record If lock_version field is NULL in database\r\n\r\n### Steps to reproduce\r\n\r\n```ruby\r\nrequire 'active_record'\r\nrequire 'minitest/autorun'\r\nrequire 'sqlite3'\r\nrequire 'logger'\r\n\r\nActiveRecord::Base.establish_connection 'sqlite3::memory:'\r\n\r\nActiveRecord::Schema.define do\r\n  create_table :posts do |t|\r\n    t.string :name\r\n    t.integer :lock_version\r\n  end\r\nend\r\n\r\nclass Post < ActiveRecord::Base\r\nend\r\n\r\nclass BugTest < Minitest::Test\r\n  def test_lock_version_without_default_value\r\n    #Post.create!(name: 'First')\r\n    ActiveRecord::Base.connection.execute(\"insert into posts(name) VALUES('Mark')\")\r\n\r\n    p1 = Post.find(1)\r\n    p1.name = \"Michael\"\r\n    p1.save\r\n  end\r\nend\r\n\r\n```\r\n\r\n### Expected behavior\r\nRecord should be updated\r\n\r\n### Actual behavior\r\nI see exception `ActiveRecord::StaleObjectError: Attempted to update a stale object: Post`\r\n\r\n### System configuration\r\n**Rails version**:\r\n4.2.7\r\n\r\n**Ruby version**:\r\nruby 2.1.8p440 (2015-12-16 revision 53160) [x86_64-darwin14.0]\r\n"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/255453456","html_url":"https://github.com/rails/rails/issues/26024#issuecomment-255453456","issue_url":"https://api.github.com/repos/rails/rails/issues/26024","id":255453456,"user":{"login":"bogdanvlviv","id":6443532,"avatar_url":"https://avatars.githubusercontent.com/u/6443532?v=3","gravatar_id":"","url":"https://api.github.com/users/bogdanvlviv","html_url":"https://github.com/bogdanvlviv","followers_url":"https://api.github.com/users/bogdanvlviv/followers","following_url":"https://api.github.com/users/bogdanvlviv/following{/other_user}","gists_url":"https://api.github.com/users/bogdanvlviv/gists{/gist_id}","starred_url":"https://api.github.com/users/bogdanvlviv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogdanvlviv/subscriptions","organizations_url":"https://api.github.com/users/bogdanvlviv/orgs","repos_url":"https://api.github.com/users/bogdanvlviv/repos","events_url":"https://api.github.com/users/bogdanvlviv/events{/privacy}","received_events_url":"https://api.github.com/users/bogdanvlviv/received_events","type":"User","site_admin":false},"created_at":"2016-10-21T20:07:31Z","updated_at":"2016-10-21T20:07:31Z","body":"Please close this issue. Fixed #26050"}}
{"actor":{"display_login":"bogdanvlviv"}}