Allow extra spaces to attribute_exists and attribute_not_exists too

This commit is contained in:
Kosei Kitahara 2018-10-12 16:59:52 +09:00
parent 2c15d71c2c
commit 13c2e69932
No known key found for this signature in database
GPG Key ID: D18883191F02241B
2 changed files with 6 additions and 6 deletions

View File

@ -204,9 +204,9 @@ class DynamoHandler(BaseResponse):
if cond_items:
expected = {}
overwrite = False
exists_re = re.compile('^attribute_exists\((.*)\)$')
exists_re = re.compile('^attribute_exists\s*\((.*)\)$')
not_exists_re = re.compile(
'^attribute_not_exists\((.*)\)$')
'^attribute_not_exists\s*\((.*)\)$')
for cond in cond_items:
exists_m = exists_re.match(cond)
@ -556,9 +556,9 @@ class DynamoHandler(BaseResponse):
if cond_items:
expected = {}
exists_re = re.compile('^attribute_exists\((.*)\)$')
exists_re = re.compile('^attribute_exists\s*\((.*)\)$')
not_exists_re = re.compile(
'^attribute_not_exists\((.*)\)$')
'^attribute_not_exists\s*\((.*)\)$')
for cond in cond_items:
exists_m = exists_re.match(cond)

View File

@ -700,8 +700,8 @@ def test_filter_expression():
filter_expr = moto.dynamodb2.comparisons.get_filter_expression('Id IN :v0', {}, {':v0': {'NS': [7, 8, 9]}})
filter_expr.expr(row1).should.be(True)
# attribute function tests
filter_expr = moto.dynamodb2.comparisons.get_filter_expression('attribute_exists(Id) AND attribute_not_exists(User)', {}, {})
# attribute function tests (with extra spaces)
filter_expr = moto.dynamodb2.comparisons.get_filter_expression('attribute_exists(Id) AND attribute_not_exists (User)', {}, {})
filter_expr.expr(row1).should.be(True)
filter_expr = moto.dynamodb2.comparisons.get_filter_expression('attribute_type(Id, N)', {}, {})