-
Notifications
You must be signed in to change notification settings - Fork 2.1k
relationJoins: fails when filtering includes by isNot: null #22311
Copy link
Copy link
Closed
prisma/prisma-engines
#4549Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.Bug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.A reported bug.topic: relationJoins
Description
with the relationJoins experimental feature toggled on, where: { volunteerEventImage: { isNot: null } } on an include seems to fail (removing that fixes the query)
Invalid `prisma.volunteer.findUnique()` invocation:
The table `(not available)` does not exist in the current database.
const volunteer = await prisma.volunteer.findUnique({
where: {
id: volunteerId,
},
select: {
name: true,
volunteerEvents: {
select: { volunteerEventImage: true },
where: { volunteerEventImage: { isNot: null } },
orderBy: [
{ archivedAt: "desc" },
{ endTime: "desc" },
{ startTime: "desc" },
],
take: 1,
},
},
});SELECT
"t1"."id",
"t1"."name",
"Volunteer_volunteerEvents_m2m"."__prisma_data__" AS "volunteerEvents"
FROM
"public"."Volunteer" AS "t1"
LEFT JOIN LATERAL (
SELECT
COALESCE(
JSON_AGG("__prisma_data__"),
'[]'
) AS "__prisma_data__"
FROM
(
SELECT
"Volunteer_volunteerEvents"."__prisma_data__"
FROM
"public"."_VolunteerToVolunteerEvent" AS "t2"
LEFT JOIN LATERAL (
SELECT
JSON_BUILD_OBJECT(
'volunteerEventImage', "VolunteerEvent_volunteerEventImage"."__prisma_data__"
) AS "__prisma_data__",
"t4"."archivedAt",
"t4"."endTime",
"t4"."startTime",
"t4"."id"
FROM
(
SELECT
"t3".*
FROM
"public"."VolunteerEvent" AS "t3"
WHERE
"t2"."B" = "t3"."id"
/* root select */
) AS "t4"
LEFT JOIN LATERAL (
SELECT
COALESCE(
JSON_AGG("__prisma_data__"),
'[]'
) AS "__prisma_data__"
FROM
(
SELECT
"t9"."__prisma_data__"
FROM
(
SELECT
JSON_BUILD_OBJECT(
'id', "t8"."id", 'createdAt', "t8"."createdAt",
'url', "t8"."url", 'volunteerEventId',
"t8"."volunteerEventId"
) AS "__prisma_data__"
FROM
(
SELECT
"t7".*
FROM
"public"."VolunteerEventImage" AS "t7"
WHERE
"t4"."id" = "t7"."volunteerEventId"
/* root select */
) AS "t8"
/* inner select */
) AS "t9"
/* middle select */
) AS "t10"
/* outer select */
) AS "VolunteerEvent_volunteerEventImage" ON true
) AS "Volunteer_volunteerEvents" ON true
LEFT JOIN "public"."VolunteerEventImage" AS "j1" ON ("j1"."volunteerEventId") = ("public"."VolunteerEvent"."id")
WHERE
(
"t2"."A" = "t1"."id"
AND (
NOT ("j1"."volunteerEventId" IS NULL)
)
)
ORDER BY
"Volunteer_volunteerEvents"."archivedAt" DESC,
"Volunteer_volunteerEvents"."endTime" DESC,
"Volunteer_volunteerEvents"."startTime" DESC
LIMIT
$1
) AS "Volunteer_volunteerEvents_m2m_1"
) AS "Volunteer_volunteerEvents_m2m" ON true
WHERE
(
"t1"."id" = $2
AND 1 = 1
)
LIMIT
$3Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.Bug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.A reported bug.topic: relationJoins