JSON filtering not working #24008
Unanswered
Aloysius999
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Hi @Aloysius999 👋 Thank you for raising htis question. I am not able to reproduce this as JSON filtering const res = await prisma.listingItem.findMany({
where: {
itemData: {
path: "$.instrument.description",
string_contains: "organ",
},
},
}); |
Beta Was this translation helpful? Give feedback.
1 reply
-
Any additional comments on this issue? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug description
I am attempting to query on the content of a JSON field.
My JSON looks like this:
My prisma query is this:
The query returns 0 records, whereas I'm expecting more than 1 record from the DB.
'
This is an extract from the Prisma-generated SQL query from the log (string quotes removed for formatting to work):
SELECT mydomain.listingItem.id, mydomain.listingItem.userId, mydomain.listingItem.createdAt, mydomain.listingItem.updatedAt, mydomain.listingItem.itemData FROM mydomain.listingItem WHERE (JSON_UNQUOTE(JSON_EXTRACT(mydomain.listingItem.itemData, ?)) LIKE ? AND (JSON_TYPE(JSON_EXTRACT(mydomain.listingItem.itemData, ?)) = ?))
and the log parameters
Params: ["$.instrument.description","%organ%","$.instrument.description","STRING"]
There appears to be no information about the instrument.description path of the
JSON_EXTRACT
function in the SQL query.Playing with the query:
returns 0 records
How to reproduce
I'm using Postman to send the query to the API.
Expected behavior
There is at least 1 record in my DB with the word organ contained in the JSON path instrument.description.
No records are being returned.
I expect matching records to be returned.
Prisma information
My prisma schema looks like this:
Environment & setup
Windows 10 Pro
Version 10.0.19045 Build 19045
MySQL
node -v
v20.10.0
next: "^14.1.4",
Prisma Version
Beta Was this translation helpful? Give feedback.
All reactions