Skip to content

Latest commit

 

History

History
165 lines (82 loc) · 8.06 KB

CHANGELOG.md

File metadata and controls

165 lines (82 loc) · 8.06 KB

Changelog

Notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Fixed

  • Keep nested model validation working in Rails post-7.1, by no longer trying to re-use ActiveRecord::Validations::AssociatedValidator, instead supplying our own custom code. #220

Added

Changed

2.3.0

Changed

  • Avoid private ActiveRecord API when lazily registering container attributes. (Compat with Rails post 7.1) #214

  • Freeze more strings to reduce String allocations #216

Added

  • Test and allow Rails 7.1 #208 Thanks @JoeSouthan

Added

  • Support for store_key in models used with polymorphic model feature. #206 . Thanks @rdubya

Fixed

  • You can now do a specified ActiveRecord .select without your json containers, to fetch an object with other attributes that you can access. #193

Changed

  • Refactor #attr_json_sync_to_rails_attributes for slightly improved performance. #192

  • Safety guard in sync_to_rails_attributes against unknown edge case where container is nil #194

While it has some backwards incompat changes, this is expected not to be a challenging upgrade, please let us know by filing an issue if it's giving you troubles, maybe we can make things easier for you. No changes to data stored in your DB should be needed when upgrading, the persisted data should be compatible between 1.x and 2.x.

Removed

  • AttrJson::Record::Dirty has been removed, along with the #attr_json_changes method. You should now be able to just use standard ActiveRecord dirty tracking with attr_json attributes. #163 (AttrJson::Record::Dirty was actually badly broken, as reported by @bemueller at #148)

  • The rails_attribute param to attr_json or attr_json_config no longer exists. We now always create rails attributes for AttrJson::Record attributes. #117 and #158

Changed

  • We now create Rails Attribute cover for all attr_json attributes, and we do a better job of keeping the Rails attribute values sync'd with attr_json values. #117, #158, and #163

  • Drop support for Rails earlier than 6.0 and ruby earlier than 2.7. #155 #174

  • Array types now default to an empty array. If you'd like to turn that off, you can use the somewhat odd default: AttrJson::AttributeDefinition::NO_DEFAULT_PROVIDED on attribute definiton. Thanks @g13ydson for suggestion. #161

  • time or datetime types used to truncate all fractional seconds to 0. Now they properly allow precision of ActiveSupport::JSON::Encoding.time_precision (normally three decimal places, ie milliseconds). And by default the Type::Value's are set to proper precision for cast too. #173

  • AttrJson::Models are serialized without nil values in the hash, for more compact representations. This is only done for attributes without defaults. This behavior can be disabled/altered when specifying the type. #175

  • config default_accepts_nested_attributes will only apply nested attributes to suitable attribute types (array or nested model), the default won't apply to inapplicable types. #178

Added

  • ActiveRecord-style "timezone-aware attribute" conversion now works properly, in both AttrJson::Record and (similarly) AttrJson::Model. #164

Fixed

  • the AttrJson::Type::Array type used for our array types was not properly tracking in-place mutation changes. Now it is #163

  • Default nested model validation should allow nils in arrays of models. #177

Added

  • AttrJson::Model#dup will properly deep-dup attributes #169

  • AttrJson::Model#freeze will freeze attributes -- but not deep-freeze. #169

  • AttrJson::Model has some methods conventional in ActiveModel classes: Klass.attribute_types, Klass.attribute_names, and instance.attribute_names. #169

Fixed

  • Fixed an obscure bug involving a conflict between attribute defaults and accepts_nested_attributes, in which defaults could overwrite assigned attributes. The .fill_in_defaults class method, which was never intended as public API and was commented accordingly, is gone. #160

Changed

  • When using store_key feature on an AttrJson::Model, you should not be able to pass in the store_key as a key in initializer or assign_attributes. It was really a bug that this ended up mapped to attribute this way, which could cause a problem in some cases; but calling it out in Changed section because if you were accidentally relying on it, it may appear as a backwards incompat to you. #125

  • Rails 7.0.0 allowed by gemspec and tested in CI

Fixed

  • polymorphic single type can be set to nil #115
  • polymorphic models can be serialized from hash in container attribute. Thanks @machty. #123
  • fix bug with deserialization of nested attributes that have types that apply different serialization vs cast logic. Thanks @bradleesand. #125

Added

  • Gemspec allows use with ActiveRecord 6.1.x

Added

  • attr_json_config(bad_cast: :as_nil) to avoid raising on data that can't be cast to a AttrJson::Model, instead just casting to nil. #95

  • Documented and tested support for using ActiveRecord serialize to map one AttrJson::Model to an entire column on it's own. #89 and #93

  • Better synchronization with ActiveRecord attributes when using rails_attribute:true, and a configurable true default_rails_attribute. Thanks @volkanunsal . #94

Changed

  • AttrJson::Model#== now requires same class for equality. And doesn't raise on certain arguments. #90 Thanks @caiofilipemr for related bug report.

Added

  • not_jsonb_contains query method, like jsonb_contains but negated. #85