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
fix(abstract): patch jsonb operator for pg if value is json #13780
Merged
Conversation
This file contains 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
Added check to traverseJSON that checks if value is JSON and passes result to jsonPathExtrationQuery Added isJson param to jsonPathExtractionQuery Updated postgres JSON join arrow to change if value is JSON with '#' will be ignored, and an empty message aborts the commit.
Added check if value is string and operator is contains Updated unit tests with new expected outputs
sdepold
reviewed
Dec 17, 2021
Could you add a test that verifies the new query? |
Added tests to validate jsonPathExtractionQuery works with and without isJSON
…elize into pg-json-array-patch
Removed extra bracket from merge conflict
Updated query generator tests to handle all supported DB types
Tests have been added and catches put in place for |
sdepold
approved these changes
Dec 22, 2021
👍 |
🎉 This PR is included in version 6.12.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
in this case
item = this.jsonPathExtractionQuery(identifier, path, true); because "order by json" is better as "order by json converted to text, including integer and float" |
Wanna file a pr? |
aliatsis
pushed a commit
to creditiq/sequelize
that referenced
this pull request
Jun 2, 2022
…e#13780) * fix(abstract): dialog query-generator for JSON in PG Added check to traverseJSON that checks if value is JSON and passes result to jsonPathExtrationQuery Added isJson param to jsonPathExtractionQuery Updated postgres JSON join arrow to change if value is JSON with '#' will be ignored, and an empty message aborts the commit. * fix(abstract): updated unit tests Added check if value is string and operator is contains Updated unit tests with new expected outputs * fix(abstract): add query generator unit tests Added tests to validate jsonPathExtractionQuery works with and without isJSON * fix(abstract): Fix merge error Removed extra bracket from merge conflict * fix(abstract): Patch failing tests Updated query generator tests to handle all supported DB types * fix(tests): update test name Co-authored-by: Sascha Depold <sdepold@users.noreply.github.com>
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.
Pull Request Checklist
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description Of Change
Issue: When querying a JSONB column in PG and the data stored in the column is an Object PG uses
#>>
when it should be#>
Updated abstract/query-generator to check the operator and value type while running _traverseJSON. If the value is a string and the operator is Op.contains it attempts to parse the value as JSON. If it doesn't fail it sends true to jsonPathExtractionQuery new third parameter isJson. This is only used in postgres so it knows to use
#>
instead of#>>
to join the query string.