prisma-engines
prisma-engines copied to clipboard
[SQL] Json filters are broken when used in combination with `NOT`
Overview
All json filters are broken when using NOT in combination with:
-
string_contains -
string_starts_with -
string_ends_with -
array_contains -
array_starts_with -
array_ends_with -
gt/gte/lt/lte
Here's an example:
{ where: { NOT: { json_field: { string_contains: "alice" } } } }
This query 👆 should search for any json_field that does not contain "alice" and that is of type string.”
As of now, instead, it searches for any json_field that does not contain "alice" and that is not of type string.
Unfortunately, this is the query we currently render:
NOT (json_field LIKE '%alice%' AND JSON_TYPE(json_field) = 'string')
This is the query we should render instead:
NOT (json_field LIKE '%alice%' OR JSON_TYPE(json_field) != 'string')
or
NOT (json_field LIKE '%alice%') AND JSON_TYPE(json_field) = 'string'