Support multi-attribute GSI partition and sort keys#206
Conversation
dimaqq
left a comment
There was a problem hiding this comment.
I'm not the maintainer, but used to work on this codebase.
I think a change like this should come with a new or updated integration test.
Add fixture and tests that exercise multi-attribute composite partition and sort keys against DynamoDB Local (skipped on unsupported backends).
Thanks, that's a good point! I've added integration tests in the latest commit. They cover various cases that DynamoDB supports. Unfortunately, not all integration testing backends support this new feature yet. DynamoDB local does, and I validated the tests against that backend. Unfortunately, Scylla and dynalite do not, so I set up the tests to skip on those backends. FWIW, moto supports this new feature, but I didn't see that as an existing backend. I'd be happy to add that though if desired. |
you can use the |
@ojii, I did set up the tests to skip on unsupported backends. One nuance is that I had to base it off of the backend name rather than I would be happy to add more granular |
expanding makes sense. basically I only added different flavors if they were needed because the implementations differed (I think currently we don't use it since all implementations are similar enough for the tests) |
Use flavor enum instead of implementation_name for skipping multi-attribute GSI tests on unsupported backends. Remove the now-unused implementation_name fixture.
Perfect! I expanded |
Closes #202
DynamoDB added support for multi-attribute composite keys on GSIs late last year. This PR adds support for that feature.
Docs: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.DesignPattern.MultiAttributeKeys.html
KeySchema now accepts tuples of
KeySpecforhash_keyandrange_key, with validation enforcing DynamoDB's 1-4 attribute limit per key type. SingleKeySpecvalues still work as before.MultiHashKey is a new expression class for querying multi-attribute partition keys:
Also fixes
HashAndRangeKeyConditionmissing__and__, which meant chaining multipleRangeKeyconditions required explicit parentheses.