Idempotent Dynamodb2 deletes

Fixes #873
This commit is contained in:
Jack Danger Canty 2017-05-01 12:31:31 -07:00
parent df84675ae6
commit 02edc6fa00
2 changed files with 7 additions and 10 deletions

View File

@ -419,16 +419,12 @@ class DynamoHandler(BaseResponse):
keys = self.body['Key']
return_values = self.body.get('ReturnValues', '')
item = dynamodb_backend2.delete_item(name, keys)
if item:
if return_values == 'ALL_OLD':
item_dict = item.to_json()
else:
item_dict = {'Attributes': {}}
item_dict['ConsumedCapacityUnits'] = 0.5
return dynamo_json_dump(item_dict)
if item and return_values == 'ALL_OLD':
item_dict = item.to_json()
else:
er = 'com.amazonaws.dynamodb.v20120810#ConditionalCheckFailedException'
return self.error(er)
item_dict = {'Attributes': {}}
item_dict['ConsumedCapacityUnits'] = 0.5
return dynamo_json_dump(item_dict)
def update_item(self):
name = self.body['TableName']

View File

@ -314,7 +314,8 @@ def test_delete_item():
response.should.equal(True)
table.count().should.equal(0)
item.delete().should.equal(False)
# Deletes are idempotent
item.delete().should.equal(True)
@requires_boto_gte("2.9")