Merge pull request #2823 from bblommers/bug/2797
DynamoDB - Allow case insensitive AND in KeyConditionExpression
This commit is contained in:
commit
dbeb16d9b9
@ -470,8 +470,10 @@ class DynamoHandler(BaseResponse):
|
||||
for k, v in six.iteritems(self.body.get("ExpressionAttributeNames", {}))
|
||||
)
|
||||
|
||||
if " AND " in key_condition_expression:
|
||||
expressions = key_condition_expression.split(" AND ", 1)
|
||||
if " and " in key_condition_expression.lower():
|
||||
expressions = re.split(
|
||||
" AND ", key_condition_expression, maxsplit=1, flags=re.IGNORECASE
|
||||
)
|
||||
|
||||
index_hash_key = [key for key in index if key["KeyType"] == "HASH"][0]
|
||||
hash_key_var = reverse_attribute_lookup.get(
|
||||
|
@ -1454,6 +1454,13 @@ def test_filter_expression():
|
||||
filter_expr.expr(row1).should.be(True)
|
||||
filter_expr.expr(row2).should.be(False)
|
||||
|
||||
# lowercase AND test
|
||||
filter_expr = moto.dynamodb2.comparisons.get_filter_expression(
|
||||
"Id > :v0 and Subs < :v1", {}, {":v0": {"N": "5"}, ":v1": {"N": "7"}}
|
||||
)
|
||||
filter_expr.expr(row1).should.be(True)
|
||||
filter_expr.expr(row2).should.be(False)
|
||||
|
||||
# OR test
|
||||
filter_expr = moto.dynamodb2.comparisons.get_filter_expression(
|
||||
"Id = :v0 OR Id=:v1", {}, {":v0": {"N": "5"}, ":v1": {"N": "8"}}
|
||||
@ -2785,7 +2792,7 @@ def test_query_gsi_with_range_key():
|
||||
res = dynamodb.query(
|
||||
TableName="test",
|
||||
IndexName="test_gsi",
|
||||
KeyConditionExpression="gsi_hash_key = :gsi_hash_key AND gsi_range_key = :gsi_range_key",
|
||||
KeyConditionExpression="gsi_hash_key = :gsi_hash_key and gsi_range_key = :gsi_range_key",
|
||||
ExpressionAttributeValues={
|
||||
":gsi_hash_key": {"S": "key1"},
|
||||
":gsi_range_key": {"S": "range1"},
|
||||
|
Loading…
Reference in New Issue
Block a user