Skip to content

Upsert and attributes that are composites of the table’s primary partition or sort keys #442

Answered by tywalch
dls314 asked this question in Q&A
Discussion options

You must be logged in to vote

I believe the reason for this is because the primary PK and SK are also the item's identifiers. So if the item was found with the composite values provided (i.e. falling into the "update" scenario of the "upsert") the composite value on the stored can be expected to match the one provided.

ElectroDB has strict constraints to keep keys and their composites in sync (failure to do so would be a serious bug), so the attribute values should always match the indexes value. As such, this operation (without if_not_exists()) is safe at best and auto healing at worst; ideally not worst though 😅

Hope this helps!

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by dls314
Comment options

You must be logged in to vote
1 reply
@tywalch
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants