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

Allow default value for String/Numeric Sets to be unset #133

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

lsglick
Copy link
Contributor

@lsglick lsglick commented Sep 25, 2023

Description of changes:

The fix in #112 had the side effect of calling type_cast on nil if the default_value was unset.

Because the StringSetMarshaler and NumericSetMarshaler both convert nil to Set.new, this caused the unset default value in practice to become Set.new instead of nil.

Ultimately this caused downstream effects such as always persisting empty or unset sets as nil despite the #persist_nil? returning false.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

The fix in aws#112 had the side effect of calling `type_cast` on `nil` if the `default_value` was unset.

Because the `StringSetMarshaler` and `NumericSetMarshaler` both convert `nil` to `Set.new`, this caused the unset default value in practice to become `Set.new` instead of `nil`.

Ultimately this caused downstream effects such as always persisting empty or unset sets as `nil` despite the `#persist_nil?` returning `false`.
Copy link
Contributor

@mullermp mullermp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you for your contribution.

@mullermp
Copy link
Contributor

We're planning a few other changes to aws-record before releasing a new version. Do you have a workaround for now?

@mullermp mullermp merged commit c75d136 into aws:main Sep 25, 2023
24 checks passed
@lsglick
Copy link
Contributor Author

lsglick commented Sep 26, 2023

Thank you!

We're planning a few other changes to aws-record before releasing a new version. Do you have a workaround for now?

@mullermp for now we can use a custom NilableStringSetMarshaler that doesn't type cast nil to Set.new, but we'll look forward to the release so we can remove that!

@lsglick lsglick deleted the lsglick/BUGFIX-set-default branch September 26, 2023 04:06
mullermp added a commit that referenced this pull request Sep 27, 2023
@mullermp
Copy link
Contributor

I've released this today among other things. Please give this a try.

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.

2 participants