feat(rds): beginsWith, between and size conditions, from table alias - #284
Merged
Conversation
Real AWS supports three `where` conditions and one `select` key that this library did not, so a resolver using any of them hit `Unhandled condition type` or a TypeError on the missing table. - `beginsWith` binds its value with a trailing wildcard (`LIKE 'x%'`) - `between` binds two values (`BETWEEN :P0 AND :P1`), guarding the arity with the two distinct messages AWS uses - `size` compares `LENGTH (col)` and accepts eq/ne/gt/ge/lt/le plus a nested `between`, repeating the target once per operator - `from` is accepted as an alias for `table`, in select() only: AWS ignores the key entirely in insert/update/remove, and rejects it alongside `table` only in select() - `contains` and `notContains` now require string values, as `beginsWith` does - an empty `size` renders nothing, so buildWhereStatement no longer wraps an empty body in the grouping parens Verified against real AWS AppSync EvaluateCode: 156 inputs match byte-for-byte across both dialects, including the #283 regression set. Snapshots recorded from AWS. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The `toThrow` assertions call the module directly and never reach `checkResolverValid`, so they are unaffected by TEST_TARGET and compare against string literals rather than AWS. The previous comments said the messages "come back from AWS", which reads as though the suite verifies them - it does not, under either target. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Motivation
Validating the empty-input fix (#283) against
EvaluateCodeturned up threewhereconditions and oneselectkey that AWS supports and this library does not, so a resolver using any of them hitsUnhandled condition typeor aTypeErroron the missing table:beginsWith: "x"→"n" LIKE :P0bound as"x%"between: [1, 9]→"n" BETWEEN :P0 AND :P1size: { eq: 3 }→LENGTH ("n") = :P0select({ from: "t" })→fromas an alias fortableChanges
rds/index.js:buildConditiondispatches before binding a value, sincebetweenneeds two variables andsizea different target expression. The simple comparisons now come from a sharedCOMPARISON_OPERATORSmap, used by both the direct form ({ eq: 1 }) and thesizeform ({ size: { eq: 1 } }).beginsWithjoinscontainsas a wildcard case, bindingvalue%rather than%value%.betweenguards its arity with the two distinct messages used upstream — one for a value that is not an array, another for an array of the wrong length — and binds each bound throughrenderValue, so a nullish bound inlinesNULLand type hints survive.sizerendersLENGTH (col)once per operator, acceptingeq/ne/gt/ge/lt/leand a nestedbetween. A nullish value is inlined here, unlike a direct comparison where it is rejected. An empty object renders nothing.fromis an alias fortableinselect()only:insert/update/removeignore the key entirely and do not reject it alongsidetable. One sharedresolveTableNamecovers all four statement types, which also gets them the'table' or 'from' key is required.message in place of aTypeError.containsandnotContainsnow require string values, asbeginsWithdoes.notContainslooked like it might be permissive — it is the one wildcard condition whose value is not wrapped — but it rejects non-strings too.buildWhereStatementno longer wraps an empty body in the grouping parens. An emptysizeis the first condition that can render to nothing inside a column, which would otherwise produceWHERE ().instays unimplemented: it is not supported upstream either.__tests__/resolvers.test.js: 48 tests in a new block, of which 33 are snapshots recorded from AWS.The other 15 assert rejected inputs. Worth being explicit about these: they call the module directly and never reach
checkResolverValid, so they are not compared against AWS under eitherTEST_TARGET— they pin string literals that were checked againstEvaluateCodeby hand. Converting them to recorded snapshots needs the harness to capture a thrown error and strip thecode.js:<line>:<col>prefix AWS puts in front of its message, which is queued on the error-parity ticket. The same caveat applies to the four such assertions #283 added, and their comment is corrected here too.No version bump or changelog line here — both land with v0.1.5.
🤖 Generated with Claude Code