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):
|
def update_item(self, table_name, key, update_expression, attribute_updates):
|
||||||
table = self.get_table(table_name)
|
table = self.get_table(table_name)
|
||||||
|
|
||||||
if table.hash_key_attr in key:
|
if all([table.hash_key_attr in key, table.range_key_attr in key]):
|
||||||
# Sometimes the key is wrapped in a dict with the key name
|
hash_value = DynamoType(key[table.hash_key_attr])
|
||||||
key = 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)
|
||||||
|
range_value = None
|
||||||
|
|
||||||
hash_value = DynamoType(key)
|
item = table.get_item(hash_value, range_value)
|
||||||
item = table.get_item(hash_value)
|
|
||||||
if update_expression:
|
if update_expression:
|
||||||
item.update(update_expression)
|
item.update(update_expression)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user