DynamoDB: scan() should respect the Projection-attribute of GSI/LSI's (#5960)
This commit is contained in:
parent
d1e3f50756
commit
03dfbe6931
@ -843,6 +843,12 @@ class Table(CloudFormationModel):
|
|||||||
if passes_all_conditions:
|
if passes_all_conditions:
|
||||||
results.append(item)
|
results.append(item)
|
||||||
|
|
||||||
|
results = copy.deepcopy(results)
|
||||||
|
if index_name:
|
||||||
|
index = self.get_index(index_name)
|
||||||
|
for result in results:
|
||||||
|
index.project(result)
|
||||||
|
|
||||||
results, last_evaluated_key = self._trim_results(
|
results, last_evaluated_key = self._trim_results(
|
||||||
results, limit, exclusive_start_key, scanned_index=index_name
|
results, limit, exclusive_start_key, scanned_index=index_name
|
||||||
)
|
)
|
||||||
|
@ -4708,6 +4708,17 @@ def test_gsi_projection_type_include():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Same when scanning the table
|
||||||
|
items = table.scan(IndexName="GSI-INC")["Items"]
|
||||||
|
items[0].should.equal(
|
||||||
|
{
|
||||||
|
"gsiK1PartitionKey": "gsi-pk",
|
||||||
|
"gsiK1SortKey": "gsi-sk",
|
||||||
|
"partitionKey": "pk-1",
|
||||||
|
"projectedAttribute": "lore ipsum",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_dynamodb
|
@mock_dynamodb
|
||||||
def test_lsi_projection_type_keys_only():
|
def test_lsi_projection_type_keys_only():
|
||||||
@ -4756,6 +4767,12 @@ def test_lsi_projection_type_keys_only():
|
|||||||
{"partitionKey": "pk-1", "sortKey": "sk-1", "lsiK1SortKey": "lsi-sk"}
|
{"partitionKey": "pk-1", "sortKey": "sk-1", "lsiK1SortKey": "lsi-sk"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Same when scanning the table
|
||||||
|
items = table.scan(IndexName="LSI")["Items"]
|
||||||
|
items[0].should.equal(
|
||||||
|
{"lsiK1SortKey": "lsi-sk", "partitionKey": "pk-1", "sortKey": "sk-1"}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_dynamodb
|
@mock_dynamodb
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
Loading…
Reference in New Issue
Block a user