DynamoDB - DELETE item from nested sets
This commit is contained in:
parent
6d7ad717df
commit
e41bc9fc58
2 changed files with 35 additions and 3 deletions
|
|
@ -1347,7 +1347,7 @@ def test_update_item_add_with_expression():
|
|||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_update_item_add_with_nested_sets_and_expression_names():
|
||||
def test_update_item_add_with_nested_sets():
|
||||
table = _create_table_with_range_key()
|
||||
|
||||
item_key = {"forum_name": "the-key", "subject": "123"}
|
||||
|
|
@ -1383,6 +1383,32 @@ def test_update_item_add_with_nested_sets_and_expression_names():
|
|||
dict(table.get_item(Key=item_key)["Item"]).should.equal(current_item)
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_update_item_delete_with_nested_sets():
|
||||
table = _create_table_with_range_key()
|
||||
|
||||
item_key = {"forum_name": "the-key", "subject": "123"}
|
||||
current_item = {
|
||||
"forum_name": "the-key",
|
||||
"subject": "123",
|
||||
"nested": {"str_set": {"item1", "item2", "item3"}},
|
||||
}
|
||||
|
||||
# Put an entry in the DB to play with
|
||||
table.put_item(Item=current_item)
|
||||
|
||||
# Update item to add a string value to a nested string set
|
||||
table.update_item(
|
||||
Key=item_key,
|
||||
UpdateExpression="DELETE nested.str_set :v",
|
||||
ExpressionAttributeValues={":v": {"item3"}},
|
||||
)
|
||||
current_item["nested"]["str_set"] = current_item["nested"]["str_set"].difference(
|
||||
{"item3"}
|
||||
)
|
||||
dict(table.get_item(Key=item_key)["Item"]).should.equal(current_item)
|
||||
|
||||
|
||||
@mock_dynamodb2
|
||||
def test_update_item_delete_with_expression():
|
||||
table = _create_table_with_range_key()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue