forked from scanamo/scanamo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add list-appending support to transactional
Update
s
This change makes list-appending support for `Update`s embedded in *transactions* consistent with the support in normal `UpdateItemRequest`s. The injection of the necessary `:emptyList` attribute has moved from `update(req: ScanamoUpdateRequest): UpdateItemRequest` into the code of `UpdateExpression`, where it can be used for both transactional and non-transactional code. # Context DynamoDB update operations let you append to existing list attributes with the `list_append()` function: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.UpdatingListElements However, if you're attempting to execute an update-append on an attribute that is not yet populated (eg the item does not even _exist_ yet), DynamoDB will return this error: ``` The provided expression refers to an attribute that does not exist in the item ``` To get friendlier behaviour, in January 2017 Scanamo PR scanamo#80 (commit 75814f9) provided an `if_not_exists()` check on the attribute, which effectively provides an empty list to append to if the attribute does not already exist. This code now lives inside the `LeafUpdateExpression` trait. Initially the test for this functionality was a doctest, but was moved to a regular test (named "Appending or prepending creates the list if it does not yet exist:") in TableTest.scala with scanamo#770.
- Loading branch information
Showing
3 changed files
with
12 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters