Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamoDB KeyExpression are not evaluated the right way #8414

Open
Kruspe opened this issue Dec 17, 2024 · 0 comments
Open

DynamoDB KeyExpression are not evaluated the right way #8414

Kruspe opened this issue Dec 17, 2024 · 0 comments

Comments

@Kruspe
Copy link

Kruspe commented Dec 17, 2024

When querying a table with a composite key like PK and SK depending on the brackets set inside the KeyConditions some queries fail.

Steps to reproduce:

  1. Parsing the following key condition does not work at all
aws dynamodb query --table-name <TABLE_NAME> --endpoint-url <MOTO_ENDPOINT> --key-condition-expression "(#0 = :0) AND (BEGINS_WITH(#1, :1))" --expression-attribute-values '{":0": {"S": "TEST"}, ":1": {"S": "ABC"}}' --expression-attribute-names '{"#0": "PK", "#1": "SK"}'

This produces the following error with moto although it is a valid query:
An error occurred (ValidationException) when calling the Query operation: Query condition missed key schema element: SK

  1. Given a table with a few entries like:
PK SK
TEST id#aa
TEST id#ab
TEST id#ad
aws dynamodb query --table-name <TABLE_NAME> --endpoint-url <MOTO_ENDPOINT> --key-condition-expression "(#0 = :0) AND (#1 BETWEEN :1 AND :2)" --expression-attribute-values '{":0": {"S": "TEST"}, ":1": {"S": "AB"}, ":2": {"S": "AB"}}' --expression-attribute-names '{"#0": "PK", "#1": "SK"}'

While this query should only return 1 item (the second item) it returns all three items from the table above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant