Description
Expected behavior vs actual behavior
c533d1a added support for key transformation to e.g. snake case or dasherized. Nice and useful however it appears to use deep_transform_keys!
. I'm not 100% sure but I have a feeling this is causing serialized models with JSON attributes (e.g. postgres JSON columns) to be mutated when they should not be.
In short serialization of a model object with JSON columns leaves that model object with dirty with unsaved (and obviously unexpected) changes.
Expected behavior is to NOT mutate model attributes during serialization.
Steps to reproduce
Setup a model with a JSON column. Serialize an instance of that object. Notice that the JSON attribute is now dirty/has changes on the model.
> model = Model.first
# Assume model.schema is a JSON attribute that is included in the serializer for Model
> ActiveModel::SerializableResource.new(model).to_json
> model.schema_changed?
true
Environment
ActiveModelSerializers Version (commit ref if not on tag): 0.10.2
Output of ruby -e "puts RUBY_DESCRIPTION"
: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin14]
OS Type & Version: OSX El Capitan
Integrated application and version (e.g., Rails, Grape, etc): Rails
Additonal helpful information
This bug is not present in versions of AMS prior to this commit: c533d1a