Skip to content
New issue

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

Add store_attribute_with_nil_value config option #360

Merged
merged 4 commits into from
Jun 1, 2019

Conversation

andrykonchin
Copy link
Member

@andrykonchin andrykonchin commented Jun 1, 2019

New config option store_attribute_with_nil_value means whether Dynamoid should store model attribute with nil value in DynamoDB item.

By default Dynamoid will continue rejecting such attributes due saving item in order to maintain current behaviour and to not introduce breaking changes.

Follow-up to #359. Related Issue #358

The reason

Recently I found out that such attributes are rejected at saving stage which I would consider as incorrect behaviour. In order to allow users to keep current behavoiur and not introduce breaking changes I would like to add this new option.

So to keep old behaviour nothing should be changed. If user want to have fixed behaviour store_attribute_with_nil_value config option should be set to true (default is nil)

Querying changes

One of the consequences of this behaviour change (storing nil value attributes) is different way to filter document with nil attributes. For instance now with old behaviour null/not_null operators should be used. With new behaviour eq/ne operators should be used.

Old behaviour:

Address.where('postcode.null': true)
Address.where('postcode.not_null': true)

New behaviour:

Address.where('postcode': nil)
Address.where('postcode.ne': nil)

@andrykonchin andrykonchin merged commit ae9152f into master Jun 1, 2019
@andrykonchin andrykonchin deleted the add-store-attribute-with-nil-value branch June 1, 2019 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant