Merge pull request #744 from helenst/scan-after-has-item

Fix failure of scan() after has_item()
This commit is contained in:
Steve Pulec 2016-11-06 09:45:12 -05:00 committed by GitHub
commit 2fdc5498b5
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()