Fix failure of scan() after has_item()

Fixes #731
This commit is contained in:
Helen Sherwood-Taylor 2016-10-25 17:09:39 +01:00
parent 2e33e2be90
commit 08d07fed30
3 changed files with 23 additions and 1 deletions

View File

@ -278,7 +278,7 @@ class DynamoHandler(BaseResponse):
result = {
"Count": len(items),
"Items": [item.attrs for item in items],
"Items": [item.attrs for item in items if item],
"ConsumedCapacityUnits": 1,
"ScannedCount": scanned_count
}

View File

@ -419,6 +419,17 @@ def test_scan_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
def test_scan_after_has_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
list(table.scan()).should.equal([])
table.has_item(hash_key='the-key', range_key='123')
list(table.scan()).should.equal([])
@mock_dynamodb
def test_write_batch():
conn = boto.connect_dynamodb()

View File

@ -335,6 +335,17 @@ def test_scan_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
def test_scan_after_has_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
list(table.scan()).should.equal([])
table.has_item('the-key')
list(table.scan()).should.equal([])
@mock_dynamodb
def test_write_batch():
conn = boto.connect_dynamodb()