byroot / activerecord-typedstore

ActiveRecord::Store but with type definition
MIT License
439 stars 57 forks source link

Decorate the original type, not replace it #48

Closed sgrif closed 7 years ago

sgrif commented 7 years ago

The current implementation will clobber the underlying datatype. This means that we lose any casting behavior that it has post-serialization, and any internal methods aren't delegated.

This specifically caused issues in Shopify core because in 4.2, Active Record column objects have access to type objects for each attribute, and delegate internal methods like type to it. In Rails 5 columns know nothing about types, and have a metadata object instead, and this was leading to cache keys for IDC having a mismatch.

decorate_attribute_type is not part of the public external API, but I super promise that it's stable and safe to rely on.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.7%) to 93.988% when pulling 1dbe1d6e48882befd659c2a846b9c39592df2356 on sgrif:sg-decorate-not-replace into ea3a85e1b03560c415175d6caf836c7366614b54 on byroot:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.02%) to 94.724% when pulling ff24c649206e92969b3237e941ebd016ad57c798 on sgrif:sg-decorate-not-replace into ea3a85e1b03560c415175d6caf836c7366614b54 on byroot:master.

rafaelfranca commented 7 years ago

@byroot only you can merge 😄

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.02%) to 94.724% when pulling 15a92b6a23325eb27efb2183af9c3beeab69d023 on sgrif:sg-decorate-not-replace into ea3a85e1b03560c415175d6caf836c7366614b54 on byroot:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.02%) to 94.724% when pulling 15a92b6a23325eb27efb2183af9c3beeab69d023 on sgrif:sg-decorate-not-replace into ea3a85e1b03560c415175d6caf836c7366614b54 on byroot:master.

byroot commented 7 years ago

Really? I though you were a contributor, hold on.

sgrif commented 7 years ago

Build is green

byroot commented 7 years ago

Made you both contributors. I'll cut a new release in the morning if it works as intended.

rafaelfranca commented 7 years ago

:+1:

byroot commented 7 years ago

1.0.1 was released.