{"action":"created","issue":{"url":"https://api.github.com/repos/xentek/dm-postgres-types/issues/8","repository_url":"https://api.github.com/repos/xentek/dm-postgres-types","labels_url":"https://api.github.com/repos/xentek/dm-postgres-types/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/xentek/dm-postgres-types/issues/8/comments","events_url":"https://api.github.com/repos/xentek/dm-postgres-types/issues/8/events","html_url":"https://github.com/xentek/dm-postgres-types/issues/8","id":207408991,"number":8,"title":"Storing and reading JSON is asymmetrical unless load_raw_value is true","user":{"login":"qwertme","id":120128,"avatar_url":"https://avatars.githubusercontent.com/u/120128?v=3","gravatar_id":"","url":"https://api.github.com/users/qwertme","html_url":"https://github.com/qwertme","followers_url":"https://api.github.com/users/qwertme/followers","following_url":"https://api.github.com/users/qwertme/following{/other_user}","gists_url":"https://api.github.com/users/qwertme/gists{/gist_id}","starred_url":"https://api.github.com/users/qwertme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qwertme/subscriptions","organizations_url":"https://api.github.com/users/qwertme/orgs","repos_url":"https://api.github.com/users/qwertme/repos","events_url":"https://api.github.com/users/qwertme/events{/privacy}","received_events_url":"https://api.github.com/users/qwertme/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-14T03:36:49Z","updated_at":"2017-02-14T03:56:15Z","closed_at":null,"body":"When not using load_raw_value for a property you still need to serialize the value when setting the property even though you can read it as a Hash.\r\n\r\nThis is confusing since it is asymmetrical. \r\n\r\nWhen load_raw_value is false I would expect that both reading and writing to the property to behave like accessing a Hash."},"comment":{"url":"https://api.github.com/repos/xentek/dm-postgres-types/issues/comments/279601296","html_url":"https://github.com/xentek/dm-postgres-types/issues/8#issuecomment-279601296","issue_url":"https://api.github.com/repos/xentek/dm-postgres-types/issues/8","id":279601296,"user":{"login":"qwertme","id":120128,"avatar_url":"https://avatars.githubusercontent.com/u/120128?v=3","gravatar_id":"","url":"https://api.github.com/users/qwertme","html_url":"https://github.com/qwertme","followers_url":"https://api.github.com/users/qwertme/followers","following_url":"https://api.github.com/users/qwertme/following{/other_user}","gists_url":"https://api.github.com/users/qwertme/gists{/gist_id}","starred_url":"https://api.github.com/users/qwertme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qwertme/subscriptions","organizations_url":"https://api.github.com/users/qwertme/orgs","repos_url":"https://api.github.com/users/qwertme/repos","events_url":"https://api.github.com/users/qwertme/events{/privacy}","received_events_url":"https://api.github.com/users/qwertme/received_events","type":"User","site_admin":false},"created_at":"2017-02-14T03:56:15Z","updated_at":"2017-02-14T03:56:15Z","body":"Here is a code example:\r\n\r\nFor this given class\r\n```\r\nclass Content\r\n  include DataMapper::Resource\r\n\r\n  property :id, Serial\r\n  property :hash_tags, String\r\n  property :text, String\r\n  property :template, String\r\n  property :parameters, PgJSON, default: {}\r\n```\r\n\r\nThe following behaviour is observed (take a look at command #13 to see the asymmetry)\r\n\r\n```\r\nirb(main):001:0> c = Content.new\r\n=> #<Content @id=nil @hash_tags=nil @text=nil @template=nil @parameters=nil>\r\nirb(main):002:0> c.parameters = {}\r\n=> {}\r\nirb(main):003:0> c.valid?\r\n=> false\r\nirb(main):004:0> c.errors.inspect\r\n=> \"#<DataMapper::Validations::ValidationErrors:0x007fd0d0b1faf0 @resource=#<Content @id=nil @hash_tags=nil @text=nil @template=nil @parameters={}>, @errors={:parameters=>[\\\"Parameters must be of type Object\\\"]}>\"\r\nirb(main):005:0> c.parameters = {}.to_json\r\n=> \"{}\"\r\nirb(main):006:0> c.valid?\r\n=> true\r\nirb(main):007:0> c.save\r\n=> true\r\nirb(main):008:0> c.reload\r\n=> #<Content @id=1 @hash_tags=<not loaded> @text=<not loaded> @template=<not loaded> @parameters=<not loaded>>\r\nirb(main):009:0> c.parameters\r\n=> {}\r\nirb(main):010:0> c.parameters['a'] = 'A'\r\n=> \"A\"\r\nirb(main):011:0> c.valid?\r\n=> false\r\nirb(main):012:0> c.errors.inspect\r\n=> \"#<DataMapper::Validations::ValidationErrors:0x007fd0d0b1faf0 @resource=#<Content @id=1 @hash_tags=nil @text=nil @template=nil @parameters={\\\"a\\\"=>\\\"A\\\"}>, @errors={:parameters=>[\\\"Parameters must be of type Object\\\"]}>\"\r\nirb(main):013:0> c.parameters = c.parameters.to_json\r\n=> \"{\\\"a\\\":\\\"A\\\"}\"\r\nirb(main):014:0> c.valid?\r\n=> true\r\n```\r\n"}}
{"actor":{"display_login":"qwertme"}}