SELECT
"child_entities"."id",
"child_entities"."slug",
"child_entities"."parentId",
"child_entities"."createdAt",
"child_entity"."updatedAt",
FROM
"child_entities" AS "child_entity"
INNER JOIN "parents" AS "parent" ON "child_entity"."parentId" = "parent"."id"
AND "parent"."name" = 'some-name'
WHERE
"child_entity"."slug" = 'some-slug'
ORDER BY
"parent.name" ASC
LIMIT
100 OFFSET 0;
The problem originates in the strict use of = at the time of joining the table, see AND "parent"."name" = 'some-name'
Expected query:
SELECT
"child_entities"."id",
"child_entities"."slug",
"child_entities"."parentId",
"child_entities"."createdAt",
"child_entity"."updatedAt",
FROM
"child_entities" AS "child_entity"
INNER JOIN "parents" AS "parent" ON "child_entity"."parentId" = "parent"."id"
AND "parent"."name" LIKE '%some-name%'
WHERE
"child_entity"."slug" = 'some-slug'
ORDER BY
"parent.name" ASC
LIMIT
100 OFFSET 0;
Note that the difference at AND "parent"."name" LIKE '%some-name%'
This bug can be reproduced with the following example:
Child Resource:
Endpoint:
/child-entity?slug=some-slug&parent.name=some-name
Query executed:
The problem originates in the strict use of
=
at the time of joining the table, seeAND "parent"."name" = 'some-name'
Expected query:
Note that the difference at
AND "parent"."name" LIKE '%some-name%'