-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Prisma text search "contains" with Join is not working #21107
Comments
This is an error message from your database. Are you sure you ran some migration that would create this table and column? |
Yes, I made sure that it was in sync |
The column doesn't actually exist because the "Formanswer.User" is an abstraction to a foreign key. But still, it should be able to work, right? |
It is trying to access data in the column |
User.full_name does exist. Before I tried to implement the code like that I used to search by the user and just join the answers, I switched to searching the answers instead because I needed to implement cursor pagination in the answer timestamp. |
I tried to reproduce your problem, but I can not run the code example in its current form as it references a field
Should I replace it? Adapt the schema? Or just comment it out @arthurguedes375? |
When I comment it out, I can indeed reproduce your error:
The SQL query:
|
Ok, analysis what is going on. This is the full query with params: SELECT
`green_wombat`.`FormAnswer`.`id`,
`green_wombat`.`FormAnswer`.`updated_at`,
`green_wombat`.`FormAnswer`.`user_id`
FROM
`green_wombat`.`FormAnswer`
WHERE
(`green_wombat`.`FormAnswer`.`id`) IN (
SELECT
`t0`.`id`
FROM
`green_wombat`.`FormAnswer` AS `t0`
INNER JOIN `green_wombat`.`User` AS `j0` ON
(`j0`.`id`) = (`t0`.`user_id`)
WHERE
(`j0`.`full_name` LIKE "%Some name%"
AND `t0`.`id` IS NOT NULL)
)
ORDER BY
MATCH (`green_wombat`.`User`.`full_name`) AGAINST ("Some name" IN BOOLEAN MODE) ASC,
`green_wombat`.`FormAnswer`.`updated_at` DESC
LIMIT 3 OFFSET 0 Note how the That is also the fix we need to implement. Something like: SELECT
`green_wombat`.`FormAnswer`.`id`,
`green_wombat`.`FormAnswer`.`updated_at`,
`green_wombat`.`FormAnswer`.`user_id`
FROM
`green_wombat`.`FormAnswer`
+ INNER JOIN `green_wombat`.`User` ON
+ (`green_wombat`.`User`.`id`) = (`green_wombat`.`FormAnswer`.`user_id`)
WHERE
(`green_wombat`.`FormAnswer`.`id`) IN (
SELECT
`t0`.`id`
FROM
`green_wombat`.`FormAnswer` AS `t0`
INNER JOIN `green_wombat`.`User` AS `j0` ON
(`j0`.`id`) = (`t0`.`user_id`)
WHERE
(`j0`.`full_name` LIKE "%Some name%"
AND `t0`.`id` IS NOT NULL)
)
ORDER BY
MATCH (`green_wombat`.`User`.`full_name`) AGAINST ("Some name" IN BOOLEAN MODE) ASC,
`green_wombat`.`FormAnswer`.`updated_at` DESC
LIMIT 3 OFFSET 0 Note the added So this is a bug in the |
Thank you for finding a solution to my problem! |
Bug description
I have a "FormAnswer" table that links to a User table that has a field called full_name.
I need to search all the "FormAnswer"s where the User name contains "x".
The problem is that it keeps returning me
How to reproduce
Just run the "prisma" code on the prisma schema and you'll get the error
Expected behavior
This code should show me every FormAnswer that the userName contains certain "name" because the auto completion also gives me the option to add the "User" to the "Where" clause.
Either the autocompletion is wrong or the prisma functionality has not been implemented correctly.
Prisma information
My code looks like this:
My query looks like this:
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: