correct looping through update actions, value stripping, hash key regex
This commit is contained in:
parent
390bef7752
commit
3c128fdb51
@ -112,11 +112,11 @@ class Item(object):
|
|||||||
|
|
||||||
def update(self, update_expression, expression_attribute_names, expression_attribute_values):
|
def update(self, update_expression, expression_attribute_names, expression_attribute_values):
|
||||||
parts = [p for p in re.split(r'\b(SET|REMOVE|ADD|DELETE)\b', update_expression) if p]
|
parts = [p for p in re.split(r'\b(SET|REMOVE|ADD|DELETE)\b', update_expression) if p]
|
||||||
for action, valstr in zip(parts[:-1:1], parts[1::1]):
|
for action, valstr in zip(parts[:-1:2], parts[1::2]):
|
||||||
values = valstr.split(',')
|
values = valstr.split(',')
|
||||||
for value in values:
|
for value in values:
|
||||||
# A Real value
|
# A Real value
|
||||||
value = value.lstrip(":").rstrip(",")
|
value = value.lstrip(":").rstrip(",").strip()
|
||||||
for k, v in expression_attribute_names.items():
|
for k, v in expression_attribute_names.items():
|
||||||
value = re.sub(r'{}\b'.format(k), v, value)
|
value = re.sub(r'{}\b'.format(k), v, value)
|
||||||
|
|
||||||
|
@ -286,7 +286,8 @@ class DynamoHandler(BaseResponse):
|
|||||||
|
|
||||||
index_hash_key = [key for key in index if key['KeyType'] == 'HASH'][0]
|
index_hash_key = [key for key in index if key['KeyType'] == 'HASH'][0]
|
||||||
hash_key_var = reverse_attribute_lookup.get(index_hash_key['AttributeName'], index_hash_key['AttributeName'])
|
hash_key_var = reverse_attribute_lookup.get(index_hash_key['AttributeName'], index_hash_key['AttributeName'])
|
||||||
i, hash_key_expression = ((i, e) for i, e in enumerate(expressions) if re.search(r'[\s(]#n1\b'.format(hash_key_var), e)).next()
|
hash_key_regex = r'(^|[\s(]){}\b'.format(hash_key_var)
|
||||||
|
i, hash_key_expression = ((i, e) for i, e in enumerate(expressions) if re.search(hash_key_regex, e)).next()
|
||||||
hash_key_expression = hash_key_expression.strip('()')
|
hash_key_expression = hash_key_expression.strip('()')
|
||||||
expressions.pop(i)
|
expressions.pop(i)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user