diff --git a/moto/dynamodb2/models.py b/moto/dynamodb2/models.py index 2b1a1b5ee..af67f5091 100644 --- a/moto/dynamodb2/models.py +++ b/moto/dynamodb2/models.py @@ -425,12 +425,17 @@ class DynamoDBBackend(BaseBackend): def update_item(self, table_name, key, update_expression, attribute_updates): table = self.get_table(table_name) - if table.hash_key_attr in key: - # Sometimes the key is wrapped in a dict with the key name - key = key[table.hash_key_attr] + if all([table.hash_key_attr in key, table.range_key_attr in key]): + hash_value = DynamoType(key[table.hash_key_attr]) + range_value = DynamoType(key[table.range_key_attr]) + elif table.hash_key_attr in key: + hash_value = DynamoType(key[table.hash_key_attr]) + range_value = None + else: + hash_value = DynamoType(key) + range_value = None - hash_value = DynamoType(key) - item = table.get_item(hash_value) + item = table.get_item(hash_value, range_value) if update_expression: item.update(update_expression) else: