feat: Add DynamoDB backend#71
Open
smitrob wants to merge 11 commits into
Open
Conversation
Adds a new `odata_query.dynamo` backend that converts OData $filter expressions directly to boto3 ConditionBase objects (no eval()). The visitor (`AstToDynamoConditionVisitor`) handles: - Comparison: eq, ne, lt, le, gt, ge - Logical: and, or, not - Membership: in, between - String functions: contains, startswith - Special: exists, not_exists - Null handling: maps `eq null` / `ne null` to DynamoDB attribute_not_exists / attribute_type semantics boto3 is an optional dependency (install with `odata-query[dynamodb]`). 163 tests, all passing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
odata_query.dynamobackend that converts OData$filterexpressions directly to boto3ConditionBaseobjects — noeval()required.This is an additive-only change. No existing files are modified.
Why
DynamoDB is a widely-used AWS database with no current OData backend in this library. The Django and SQLAlchemy backends produce SQL strings, but DynamoDB uses a completely different expression model (boto3 condition objects). A dedicated visitor closes that gap cleanly.
What's Added
odata_query/dynamo/(new backend module)base.py—AstToDynamoConditionVisitor— walks the OData AST and returns live boto3ConditionBaseobjects at every node__init__.py— exportsAstToDynamoConditionVisitorandapply_odata_querySupported OData operations:
eq,ne,lt,le,gt,geand,or,notin,betweencontains,startswithexists,not_existseq null→not_exists OR attribute_type('NULL');ne null→exists AND NOT attribute_type('NULL')Unsupported functions (e.g.
endswith) raiseUnsupportedFunctionExceptionimmediately — no silent fallback.tests/test_dynamodb_backend.py20 tests covering all operators, boolean logic, null semantics, nested paths, and error cases.
Usage
Backward Compatibility
ast.py,grammar.py,visitor.py, or any existing backendboto3is an optional dependency — doesn't affect core package installsDependencies
boto3should be added as an optional extra inpyproject.toml:I've left
pyproject.tomlunchanged in this PR so maintainers can apply the version pin they prefer.