Merge pull request #1559 from sawandas/master
Issue #1539 : support more dynamoDb query filters
This commit is contained in:
commit
9398f03cdc
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user