Deleting from an unknown table raises error
If the table exists then we deletes are idempotent
This commit is contained in:
parent
02edc6fa00
commit
8e3d46fb05
@ -659,7 +659,7 @@ class DynamoDBBackend(BaseBackend):
|
||||
return item
|
||||
|
||||
def delete_item(self, table_name, keys):
|
||||
table = self.tables.get(table_name)
|
||||
table = self.get_table(table_name)
|
||||
if not table:
|
||||
return None
|
||||
hash_key, range_key = self.get_keys_value(table, keys)
|
||||
|
@ -418,6 +418,11 @@ class DynamoHandler(BaseResponse):
|
||||
name = self.body['TableName']
|
||||
keys = self.body['Key']
|
||||
return_values = self.body.get('ReturnValues', '')
|
||||
table = dynamodb_backend2.get_table(name)
|
||||
if not table:
|
||||
er = 'com.amazonaws.dynamodb.v20120810#ConditionalCheckFailedException'
|
||||
return self.error(er)
|
||||
|
||||
item = dynamodb_backend2.delete_item(name, keys)
|
||||
if item and return_values == 'ALL_OLD':
|
||||
item_dict = item.to_json()
|
||||
|
@ -199,7 +199,8 @@ def test_delete_item():
|
||||
|
||||
table.count().should.equal(0)
|
||||
|
||||
item.delete().should.equal(False)
|
||||
# Deletes are idempotent and 'False' here would imply an error condition
|
||||
item.delete().should.equal(True)
|
||||
|
||||
|
||||
@requires_boto_gte("2.9")
|
||||
|
Loading…
Reference in New Issue
Block a user