Add DynamoDB tests for update_item() with UpdateExpression, support spaces in the UpdateExpression. (#758)

Fixes #745.
This commit is contained in:
Nuno Santos 2016-11-11 23:04:14 +01:00 committed by Steve Pulec
commit 71c1fbadbe
2 changed files with 39 additions and 0 deletions

View file

@ -419,6 +419,12 @@ class DynamoHandler(BaseResponse):
expression_attribute_names = self.body.get('ExpressionAttributeNames', {})
expression_attribute_values = self.body.get('ExpressionAttributeValues', {})
existing_item = dynamodb_backend2.get_item(name, key)
# Support spaces between operators in an update expression
# E.g. `a = b + c` -> `a=b+c`
if update_expression:
update_expression = re.sub('\s*([=\+-])\s*', '\\1', update_expression)
item = dynamodb_backend2.update_item(name, key, update_expression, attribute_updates, expression_attribute_names, expression_attribute_values)
item_dict = item.to_json()