fix for scanning without filter
This commit is contained in:
parent
d29ca8503e
commit
a5eaaaad51
@ -244,7 +244,7 @@ class DynamoHandler(object):
|
|||||||
name = body['TableName']
|
name = body['TableName']
|
||||||
|
|
||||||
filters = {}
|
filters = {}
|
||||||
scan_filters = body['ScanFilter']
|
scan_filters = body.get('ScanFilter', {})
|
||||||
for attribute_name, scan_filter in scan_filters.iteritems():
|
for attribute_name, scan_filter in scan_filters.iteritems():
|
||||||
# Keys are attribute names. Values are tuples of (comparison, comparison_value)
|
# Keys are attribute names. Values are tuples of (comparison, comparison_value)
|
||||||
comparison_operator = scan_filter["ComparisonOperator"]
|
comparison_operator = scan_filter["ComparisonOperator"]
|
||||||
|
@ -135,7 +135,7 @@ def test_item_put_without_table():
|
|||||||
|
|
||||||
conn.layer1.put_item.when.called_with(
|
conn.layer1.put_item.when.called_with(
|
||||||
table_name='undeclared-table',
|
table_name='undeclared-table',
|
||||||
item =dict(
|
item=dict(
|
||||||
hash_key='LOLCat Forum',
|
hash_key='LOLCat Forum',
|
||||||
range_key='Check this out!',
|
range_key='Check this out!',
|
||||||
),
|
),
|
||||||
@ -302,10 +302,10 @@ def test_query_with_undeclared_table():
|
|||||||
table_name='undeclared-table',
|
table_name='undeclared-table',
|
||||||
hash_key_value={'S': 'the-key'},
|
hash_key_value={'S': 'the-key'},
|
||||||
range_key_conditions={
|
range_key_conditions={
|
||||||
"AttributeValueList":[{
|
"AttributeValueList": [{
|
||||||
"S":"User B"
|
"S": "User B"
|
||||||
}],
|
}],
|
||||||
"ComparisonOperator":"EQ",
|
"ComparisonOperator": "EQ",
|
||||||
},
|
},
|
||||||
).should.throw(DynamoDBResponseError)
|
).should.throw(DynamoDBResponseError)
|
||||||
|
|
||||||
@ -348,6 +348,9 @@ def test_scan():
|
|||||||
)
|
)
|
||||||
item.put()
|
item.put()
|
||||||
|
|
||||||
|
results = table.scan()
|
||||||
|
results.response['Items'].should.have.length_of(3)
|
||||||
|
|
||||||
results = table.scan(scan_filter={'SentBy': condition.EQ('User B')})
|
results = table.scan(scan_filter={'SentBy': condition.EQ('User B')})
|
||||||
results.response['Items'].should.have.length_of(1)
|
results.response['Items'].should.have.length_of(1)
|
||||||
|
|
||||||
@ -378,10 +381,10 @@ def test_scan_with_undeclared_table():
|
|||||||
table_name='undeclared-table',
|
table_name='undeclared-table',
|
||||||
scan_filter={
|
scan_filter={
|
||||||
"SentBy": {
|
"SentBy": {
|
||||||
"AttributeValueList":[{
|
"AttributeValueList": [{
|
||||||
"S":"User B"}
|
"S": "User B"}
|
||||||
],
|
],
|
||||||
"ComparisonOperator":"EQ"
|
"ComparisonOperator": "EQ"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
).should.throw(DynamoDBResponseError)
|
).should.throw(DynamoDBResponseError)
|
||||||
|
@ -291,6 +291,9 @@ def test_scan():
|
|||||||
)
|
)
|
||||||
item.put()
|
item.put()
|
||||||
|
|
||||||
|
results = table.scan()
|
||||||
|
results.response['Items'].should.have.length_of(3)
|
||||||
|
|
||||||
results = table.scan(scan_filter={'SentBy': condition.EQ('User B')})
|
results = table.scan(scan_filter={'SentBy': condition.EQ('User B')})
|
||||||
results.response['Items'].should.have.length_of(1)
|
results.response['Items'].should.have.length_of(1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user