Fix JSON Path Filtering Producing Incorrect Results#17
Closed
kac-axelor wants to merge 5 commits intoaxelor:devfrom
Closed
Fix JSON Path Filtering Producing Incorrect Results#17kac-axelor wants to merge 5 commits intoaxelor:devfrom
kac-axelor wants to merge 5 commits intoaxelor:devfrom
Conversation
- Add null and undefined guards to findJsonType - Ensure regex tests only run on string values to avoid false positives and errors
- Fixes 'between' and 'in' operators where only the first occurrence was being cast - Ensures all field placeholders in complex JSON path conditions are correctly processed
- Casts both the field (@) and the parameter variable () to .double() or .datetime() - Ensures PostgreSQL jsonpath engine compares identical types, avoiding strict type-mismatch errors - Update query parser tests to reflect symmetric casts
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.
Symmetric casting for JSON path parameters
PostgreSQL's jsonpath engine requires both sides of a comparison to be the same type. Previously only the field placeholder (
@) was cast to.double()or.datetime()— the parameter variable (e.g.$p0) was left uncast, causing strict type-mismatch errors at runtime. Both sides are now cast symmetrically.Global regex for
@replacementThe
@placeholder replacement used a non-global regex, so only the first occurrence was cast. This brokebetweenandinoperators which generate multiple@references in a single condition. Replaced with/gflag to cast all occurrences.Safer type inference in
findJsonTypefindJsonTyperan regex tests directly on the value without checking its type first. Passingnull,undefined, or a non-string (e.g. aDateobject orboolean) would either throw or produce the wrong inferred type. Added null/undefined guards and wrapped the regex checks inside atypeof value === "string"guard.Test cases to demonstrate the issue
Added test cases that would fail without these fixes