Fix dynamodb2 KEYS_ONLY Indexes (#3125)

KEYS_ONLY indexes include table keys.
This commit is contained in:
Mike Fogel 2020-07-14 09:42:13 -03:00 committed by GitHub
commit 9072153474
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 13 deletions

View file

@ -5358,14 +5358,23 @@ def test_gsi_projection_type_keys_only():
IndexName="GSI-K1",
)["Items"]
items.should.have.length_of(1)
# Item should only include GSI Keys, as per the ProjectionType
items[0].should.equal({"gsiK1PartitionKey": "gsi-pk", "gsiK1SortKey": "gsi-sk"})
# Item should only include GSI Keys and Table Keys, as per the ProjectionType
items[0].should.equal(
{
"gsiK1PartitionKey": "gsi-pk",
"gsiK1SortKey": "gsi-sk",
"partitionKey": "pk-1",
}
)
@mock_dynamodb2
def test_lsi_projection_type_keys_only():
table_schema = {
"KeySchema": [{"AttributeName": "partitionKey", "KeyType": "HASH"}],
"KeySchema": [
{"AttributeName": "partitionKey", "KeyType": "HASH"},
{"AttributeName": "sortKey", "KeyType": "RANGE"},
],
"LocalSecondaryIndexes": [
{
"IndexName": "LSI",
@ -5378,12 +5387,14 @@ def test_lsi_projection_type_keys_only():
],
"AttributeDefinitions": [
{"AttributeName": "partitionKey", "AttributeType": "S"},
{"AttributeName": "sortKey", "AttributeType": "S"},
{"AttributeName": "lsiK1SortKey", "AttributeType": "S"},
],
}
item = {
"partitionKey": "pk-1",
"sortKey": "sk-1",
"lsiK1SortKey": "lsi-sk",
"someAttribute": "lore ipsum",
}
@ -5399,5 +5410,7 @@ def test_lsi_projection_type_keys_only():
KeyConditionExpression=Key("partitionKey").eq("pk-1"), IndexName="LSI",
)["Items"]
items.should.have.length_of(1)
# Item should only include GSI Keys, as per the ProjectionType
items[0].should.equal({"partitionKey": "pk-1", "lsiK1SortKey": "lsi-sk"})
# Item should only include GSI Keys and Table Keys, as per the ProjectionType
items[0].should.equal(
{"partitionKey": "pk-1", "sortKey": "sk-1", "lsiK1SortKey": "lsi-sk"}
)