Merge pull request #1333 from terrycain/fix_1043

DynamoDB: Fixed requiring optional parameter
This commit is contained in:
Jack Danger 2017-11-11 14:06:51 -08:00 committed by GitHub
commit 123f369e6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 3 deletions

View file

@ -311,7 +311,7 @@ class DynamoHandler(BaseResponse):
filter_kwargs = {}
if key_condition_expression:
value_alias_map = self.body['ExpressionAttributeValues']
value_alias_map = self.body.get('ExpressionAttributeValues', {})
table = self.dynamodb_backend.get_table(name)
@ -336,7 +336,7 @@ class DynamoHandler(BaseResponse):
index = table.schema
reverse_attribute_lookup = dict((v, k) for k, v in
six.iteritems(self.body['ExpressionAttributeNames']))
six.iteritems(self.body.get('ExpressionAttributeNames', {})))
if " AND " in key_condition_expression:
expressions = key_condition_expression.split(" AND ", 1)
@ -375,7 +375,8 @@ class DynamoHandler(BaseResponse):
range_values = []
hash_key_value_alias = hash_key_expression.split("=")[1].strip()
hash_key = value_alias_map[hash_key_value_alias]
# Temporary fix until we get proper KeyConditionExpression function
hash_key = value_alias_map.get(hash_key_value_alias, {'S': hash_key_value_alias})
else:
# 'KeyConditions': {u'forum_name': {u'ComparisonOperator': u'EQ', u'AttributeValueList': [{u'S': u'the-key'}]}}
key_conditions = self.body.get('KeyConditions')