2022-10-13 10:09:18 +00:00
|
|
|
import boto3
|
|
|
|
from moto import mock_dynamodb
|
|
|
|
|
|
|
|
|
|
|
|
@mock_dynamodb
|
|
|
|
def test_update_different_map_elements_in_single_request():
|
2023-01-07 11:35:14 +00:00
|
|
|
# https://github.com/getmoto/moto/issues/5552
|
2022-10-13 10:09:18 +00:00
|
|
|
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
|
|
|
|
dynamodb.create_table(
|
|
|
|
TableName="example_table",
|
|
|
|
KeySchema=[{"AttributeName": "id", "KeyType": "HASH"}],
|
|
|
|
AttributeDefinitions=[
|
|
|
|
{"AttributeName": "id", "AttributeType": "S"},
|
|
|
|
],
|
|
|
|
BillingMode="PAY_PER_REQUEST",
|
|
|
|
)
|
|
|
|
record = {
|
|
|
|
"id": "example_id",
|
|
|
|
"d": {"hello": "h", "world": "w"},
|
|
|
|
}
|
|
|
|
table = dynamodb.Table("example_table")
|
|
|
|
table.put_item(Item=record)
|
|
|
|
updated = table.update_item(
|
|
|
|
Key={"id": "example_id"},
|
|
|
|
UpdateExpression="set d.hello = :h, d.world = :w",
|
|
|
|
ExpressionAttributeValues={":h": "H", ":w": "W"},
|
|
|
|
ReturnValues="ALL_NEW",
|
|
|
|
)
|
2023-07-13 10:21:47 +00:00
|
|
|
assert updated["Attributes"] == {
|
|
|
|
"id": "example_id",
|
|
|
|
"d": {"hello": "H", "world": "W"},
|
|
|
|
}
|