You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a case where were updating an entity Foo in a transaction that has a unique attribute "name". In this update transaction, we are not updating the "unique" attribute.
We are receiving the following error from dynamodb:
“message”:“Unable to edit task due to error: ValidationException: Transaction request cannot include multiple operations on one item”
upon turning on typedorm:* DEBUG logging - we see that two new writes are being added to the transaction, a PUT and a DELETE of the same autogenerated id value (I presume this is what's being used to calculate uniqueness) - dynamodb doesn't like this because we're trying to do two operations on the same key in the same transaction.
I think this is happening because in the update, we're not changing the "name" attribute of Foo - if we do change the "name" attribute, the transaction succeeds because we'll preform a DELETE on the old unique key and a PUT on on the new unique key
Do we just need to change this function to compare the old value and new value of the unique attribute, if it's not changing then we don't need to append the PUT and DELETE writes to the transaction?
I just wanted to confirm my suspicions with someone more familiar with the library before going further.
The text was updated successfully, but these errors were encountered:
brendanclement
changed the title
Transaction failing when updating entity with unique item
Transaction failing when updating entity with unique item and not updating unique value
May 26, 2023
We have a case where were updating an entity
Foo
in a transaction that has a unique attribute "name". In this update transaction, we are not updating the "unique" attribute.We are receiving the following error from dynamodb:
upon turning on typedorm:* DEBUG logging - we see that two new writes are being added to the transaction, a PUT and a DELETE of the same autogenerated id value (I presume this is what's being used to calculate uniqueness) - dynamodb doesn't like this because we're trying to do two operations on the same key in the same transaction.
I think this is happening because in the update, we're not changing the "name" attribute of Foo - if we do change the "name" attribute, the transaction succeeds because we'll preform a DELETE on the old unique key and a PUT on on the new unique key
I took a look through the code and I think I understand what's going on.
Propose a fix:
typedorm/packages/core/src/classes/transformer/document-client-request-transformer.ts
Line 1098 in b69818c
typedorm/packages/core/src/classes/transformer/document-client-request-transformer.ts
Line 1080 in b69818c
PUT
andDELETE
writes to the transaction?The text was updated successfully, but these errors were encountered: