Skip to content

Commit

Permalink
Handle delete updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcraciunoiu committed Jan 4, 2016
1 parent 1ee7112 commit 4655d4a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions moto/dynamodb2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def update(self, update_expression):
def update_with_attribute_updates(self, attribute_updates):
for attribute_name, update_action in attribute_updates.items():
action = update_action['Action']
if action == 'DELETE' and not 'Value' in update_action:
del self.attrs[attribute_name]
continue
new_value = list(update_action['Value'].values())[0]
if action == 'PUT':
# TODO deal with other types
Expand All @@ -133,6 +136,8 @@ def update_with_attribute_updates(self, attribute_updates):
self.attrs[attribute_name] = DynamoType({"M": new_value})
elif update_action['Value'].keys() == ['N']:
self.attrs[attribute_name] = DynamoType({"N": new_value})
elif update_action['Value'].keys() == ['NULL']:
del self.attrs[attribute_name]
else:
self.attrs[attribute_name] = DynamoType({"S": new_value})

Expand Down

0 comments on commit 4655d4a

Please sign in to comment.