aws / aws-sdk-ruby-record

Official repository for the aws-record gem, an abstraction for Amazon DynamoDB.
Apache License 2.0
318 stars 41 forks source link

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

Closed lsglick closed 1 year ago

lsglick commented 1 year ago

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.

mullermp commented 1 year ago

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

lsglick commented 1 year ago

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!

mullermp commented 1 year ago

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