Fixes #150, which tracks a breaking change in serialization and persistence of json object.
After v1.6.2, nested models received multiple serialization passes. This broke all json queries against the persisted rows. I merged in the test which @trumanshuck used to isolate the version, then added a fix from there.
This PR removes values_for_database and patches as_json so nested Hash and StoreModel attributes will only serialized as JSON once. For array attributes, it delegates to as_json, so they are safe as well.
This ensures:
the entire object and all nested attributes are query-able through your database's particular json syntax
all nested attribute's Type will be used for serialization/deserialization, so things like timestamps and encryption work.
Fixes #150, which tracks a breaking change in serialization and persistence of json object.
After
v1.6.2
, nested models received multiple serialization passes. This broke all json queries against the persisted rows. I merged in the test which @trumanshuck used to isolate the version, then added a fix from there.This PR removes
values_for_database
and patchesas_json
so nestedHash
andStoreModel
attributes will only serialized as JSON once. For array attributes, it delegates toas_json
, so they are safe as well.This ensures:
Type
will be used for serialization/deserialization, so things like timestamps and encryption work.