We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
This is confusing since it is asymmetrical.
When load_raw_value is false I would expect that both reading and writing to the property to behave like accessing a Hash.
The text was updated successfully, but these errors were encountered:
Here is a code example:
For this given class
class Content include DataMapper::Resource property :id, Serial property :hash_tags, String property :text, String property :template, String property :parameters, PgJSON, default: {}
The following behaviour is observed (take a look at command #13 to see the asymmetry)
irb(main):001:0> c = Content.new => #<Content @id=nil @hash_tags=nil @text=nil @template=nil @parameters=nil> irb(main):002:0> c.parameters = {} => {} irb(main):003:0> c.valid? => false irb(main):004:0> c.errors.inspect => "#<DataMapper::Validations::ValidationErrors:0x007fd0d0b1faf0 @resource=#<Content @id=nil @hash_tags=nil @text=nil @template=nil @parameters={}>, @errors={:parameters=>[\"Parameters must be of type Object\"]}>" irb(main):005:0> c.parameters = {}.to_json => "{}" irb(main):006:0> c.valid? => true irb(main):007:0> c.save => true irb(main):008:0> c.reload => #<Content @id=1 @hash_tags=<not loaded> @text=<not loaded> @template=<not loaded> @parameters=<not loaded>> irb(main):009:0> c.parameters => {} irb(main):010:0> c.parameters['a'] = 'A' => "A" irb(main):011:0> c.valid? => false irb(main):012:0> c.errors.inspect => "#<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\"]}>" irb(main):013:0> c.parameters = c.parameters.to_json => "{\"a\":\"A\"}" irb(main):014:0> c.valid? => true
Sorry, something went wrong.
No branches or pull requests
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.
This is confusing since it is asymmetrical.
When load_raw_value is false I would expect that both reading and writing to the property to behave like accessing a Hash.
The text was updated successfully, but these errors were encountered: