-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
How to handle empty HashSet attributes? #152
Comments
Is the serialized set always empty (regardless of the state of your
Unfortunately I don't yet have sufficient relevant experience to comment further. |
When the HashSet<_> is not empty the serialization is correct.
The challenge is adding to an empty set.
DynamoDB supports using the ADD update expression. If the set attribute
exists it will add the item to the set. If it doesn't exist, dynamodb will
create it.
However, in this case it's kind of a problem.
We can't have an empty set (not supported by DynamoDB) and we can't not
have the attribute at all either (as dynomite) always creates it.
As a workaround I ended up making sure the set is never empty.
Not sure this is the best approach, but I did want to keep the attribute
defined as a set in order to use the contains update-condition-expression
…On Wed, Jan 20, 2021 at 9:16 PM taryn ***@***.***> wrote:
When I try to create such an item in DynamoDB it seems like the hashset is
translated to an attribute of type SS with an empty set of values { "SS":
[] }.
Is the serialized set *always* empty (regardless of the state of your
HashSet<_>)?
If so, that's be a bug (in dynomite).
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes.SetTypes
tells us
DynamoDB does not support empty sets
Unfortunately I don't yet have sufficient relevant experience to comment
further.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#152 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAQ5JXBXPBGKXQTJC76YHTS24TYPANCNFSM4WEGWKDA>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I'm new to Rust and Dynomite. Have some experience with DynamoDB.
Hope my question makes sense.
I'd like to have an item with an attribute of type HashSet.
When I try to create such an item in DynamoDB it seems like the hashset is translated to an attribute of type SS with an empty set of values { "SS": [] }. This is not permitted by DynamoDB and returns an error.
Alternatively, when I define the attribute as an Option (initialized to None) the resulting Item has a NULL attribute { "NULL": true }
The challenge with the NULL attribute is that subsequent update expressions such as "ADD friends :v" no longer work, as the attribute type is not a Set.
Any advice / best-practices ?
Thanks,
The text was updated successfully, but these errors were encountered: