Merge pull request #1559 from sawandas/master

Issue #1539 : support more dynamoDb query filters
This commit is contained in:
Steve Pulec 2018-04-12 18:45:58 -04:00 committed by GitHub
commit 9398f03cdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -176,6 +176,8 @@ def get_filter_expression(expr, names, values):
next_token = six.next(token_iterator)
while next_token != ')':
if next_token in values_map:
next_token = values_map[next_token]
function_list.append(next_token)
next_token = six.next(token_iterator)

View File

@ -658,6 +658,14 @@ def test_filter_expression():
{':v0': {'N': '7'}}
)
filter_expr.expr(row1).should.be(True)
# Expression from to check contains on string value
filter_expr = moto.dynamodb2.comparisons.get_filter_expression(
'contains(#n0, :v0)',
{'#n0': 'Desc'},
{':v0': {'S': 'Some'}}
)
filter_expr.expr(row1).should.be(True)
filter_expr.expr(row2).should.be(False)
@mock_dynamodb2
@ -699,6 +707,11 @@ def test_query_filter():
)
assert response['Count'] == 1
assert response['Items'][0]['app'] == 'app2'
response = table.query(
KeyConditionExpression=Key('client').eq('client1'),
FilterExpression=Attr('app').contains('app')
)
assert response['Count'] == 2
@mock_dynamodb2