{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/9679","labels_url":"https://api.github.com/repos/rails/rails/issues/9679/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/9679/comments","events_url":"https://api.github.com/repos/rails/rails/issues/9679/events","html_url":"https://github.com/rails/rails/issues/9679","id":11907017,"number":9679,"title":".first_or_initialize doesn't set key/value on hstore column","user":{"login":"rynmng","id":144899,"avatar_url":"https://avatars.githubusercontent.com/u/144899?v=3","gravatar_id":"","url":"https://api.github.com/users/rynmng","html_url":"https://github.com/rynmng","followers_url":"https://api.github.com/users/rynmng/followers","following_url":"https://api.github.com/users/rynmng/following{/other_user}","gists_url":"https://api.github.com/users/rynmng/gists{/gist_id}","starred_url":"https://api.github.com/users/rynmng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rynmng/subscriptions","organizations_url":"https://api.github.com/users/rynmng/orgs","repos_url":"https://api.github.com/users/rynmng/repos","events_url":"https://api.github.com/users/rynmng/events{/privacy}","received_events_url":"https://api.github.com/users/rynmng/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/PostgreSQL","name":"PostgreSQL","color":"fbca04"},{"url":"https://api.github.com/repos/rails/rails/labels/stale","name":"stale","color":"444444"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2013-03-12T02:12:03Z","updated_at":"2015-12-23T17:45:38Z","closed_at":null,"body":"This was tested on a new Rails 4 beta-1 install using Postgres.\r\n\r\nWhen there isn't an existing Product that matches, I'd normally expect first_or_initialize to set the field specified in the 'where' clause. In this case, the match takes place on an hstore column.\r\n\r\nSo I would expect for:\r\n````ruby\r\n@product = Product.where( \"properties -> 'rating' = 'PG-13'\" ).first_or_initialize\r\n@product.rating == 'PG-13'  # this doesn't work; rating is nil\r\n````\r\nSample code, test and output here:\r\nhttps://gist.github.com/rynmng/5139435"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/166954479","html_url":"https://github.com/rails/rails/issues/9679#issuecomment-166954479","issue_url":"https://api.github.com/repos/rails/rails/issues/9679","id":166954479,"user":{"login":"joevandyk","id":1179,"avatar_url":"https://avatars.githubusercontent.com/u/1179?v=3","gravatar_id":"","url":"https://api.github.com/users/joevandyk","html_url":"https://github.com/joevandyk","followers_url":"https://api.github.com/users/joevandyk/followers","following_url":"https://api.github.com/users/joevandyk/following{/other_user}","gists_url":"https://api.github.com/users/joevandyk/gists{/gist_id}","starred_url":"https://api.github.com/users/joevandyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joevandyk/subscriptions","organizations_url":"https://api.github.com/users/joevandyk/orgs","repos_url":"https://api.github.com/users/joevandyk/repos","events_url":"https://api.github.com/users/joevandyk/events{/privacy}","received_events_url":"https://api.github.com/users/joevandyk/received_events","type":"User","site_admin":false},"created_at":"2015-12-23T17:45:38Z","updated_at":"2015-12-23T17:45:38Z","body":"it's still a problem in 4-2-stable.\n\nOn Wed, Dec 23, 2015 at 9:38 AM, Ruby on Rails Bot <notifications@github.com\n> wrote:\n\n> This issue has been automatically marked as stale because it has not been\n> commented on for at least\n> three months.\n>\n> The resources of the Rails team are limited, and so we are asking for your\n> help.\n>\n> If you can still reproduce this error on the 4-2-stable, 4-1-stable\n> branches or on master,\n> please reply with all of the information you have about it in order to\n> keep the issue open.\n>\n> Thank you for all your contributions.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/rails/rails/issues/9679#issuecomment-166952160>.\n>\n"}}