feature: support sqlite contains path queries #274
Merged
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.
Checks
What did this pull request do?
Support using path for SQLite JSON array contains queries.
This addresses issue #216 to some extent.
Use case description
If we have
For SQLite databases, we can now do
This gets translated to
Note the additional
json_array_length
check compared to the previous implementation.This fixes the inconsistency in the behaviour between the MySQL and SQLite dialects.
Previously, if we have
When we do
The where condition is translated to
This returns the row
{"a": 1}
because thefor_each
function iterates over the map as well. Andthe key-value pair
"a"
and1
fulfils the query criteriaWHERE value=1
. This behaviour isdifferent from the MySQL implementation.
With this change, the where condition gets translated to
json_array_length
for a non-array object is 0, and therefore the second where clause is false. Additionally,any contains query should return false for an empty target array.