Added support for partial_save on tables with a hash and range key; Issue #498
This commit is contained in:
parent
159e88db53
commit
a0ed89c92d
@ -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)
|
||||
item = table.get_item(hash_value)
|
||||
range_value = None
|
||||
|
||||
item = table.get_item(hash_value, range_value)
|
||||
if update_expression:
|
||||
item.update(update_expression)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user