From f1099dd0063334502253b2cdf2f3ff138606205e Mon Sep 17 00:00:00 2001 From: Paul Craciunoiu Date: Mon, 21 Dec 2015 16:45:08 -0700 Subject: [PATCH] Support update_item with map and numeric types. --- moto/dynamodb2/models.py | 4 ++++ .../test_dynamodb_table_with_range_key.py | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/moto/dynamodb2/models.py b/moto/dynamodb2/models.py index 99ace6da0..5aa870b48 100644 --- a/moto/dynamodb2/models.py +++ b/moto/dynamodb2/models.py @@ -129,6 +129,10 @@ class Item(object): # TODO deal with other types if isinstance(new_value, list) or isinstance(new_value, set): self.attrs[attribute_name] = DynamoType({"SS": new_value}) + elif isinstance(new_value, dict): + self.attrs[attribute_name] = DynamoType({"M": new_value}) + elif update_action['Value'].keys() == ['N']: + self.attrs[attribute_name] = DynamoType({"N": new_value}) else: self.attrs[attribute_name] = DynamoType({"S": new_value}) diff --git a/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py b/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py index 661c6c977..639fc0687 100644 --- a/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py +++ b/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py @@ -807,6 +807,14 @@ def test_update_item_range_key_set(): 'Action': u'PUT', 'Value': 'johndoe2' }, + 'created': { + 'Action': u'PUT', + 'Value': Decimal('4'), + }, + 'mapfield': { + 'Action': u'PUT', + 'Value': {'key': 'value'}, + } }, ) @@ -815,7 +823,8 @@ def test_update_item_range_key_set(): 'username': "johndoe2", 'forum_name': 'the-key', 'subject': '123', - 'created': Decimal('3'), + 'created': Decimal('4'), + 'mapfield': {'key': 'value'}, })