Closed happylinks closed 2 months ago
This is a common misconception with regard to condition expressions. The intent of create
is to fail if an item already exists with a given primary key (partition key + sort key).
In the case where an item with a given primary key doesn't exist, then none of the attributes (including the partition key) exist, and so the condition succeeds.
In the case where an item with a given primary key does exist, then the partition key will exist, and so the condition will fail.
Check out this article from Alex DeBrie on Condition Expressions for more information, and let me know if this doesn't answer your question.
Thanks, I indeed wasn't aware of that behavior! So basically it first checks if the combination exists and returns that to evaluate the condition expressions on. So then I think my conditional request failed issue is caused by something else, will look into it! Thanks for explaining it to me :)
Hey there,
I just ran into an issue with "The conditional request failed" where it seems like PK has to be unique by itself, but I'm not sure if that's correct: https://github.com/neoeinstein/modyne/blob/main/modyne/src/lib.rs#L361-L371
In dynamodb the combination of PK and SK should be unique, but PK by itself doesn't have to be right?
Is this code wrong or am I missing some other error maybe.
Edit: noticed I can just use .put() instead, it seems like modyne assumes that PK should be unique by itself by design. Would still be interested to know why.