Description and expected behavior
omit: { id: true } on an ordered nested relation drops the PK from the derived subquery, breaking further nested includes (column "$$tN"."id" does not exist)
await db.parent.findMany({
include: {
children: {
omit: { id: true },
orderBy: { position: "asc" },
include: { grandchildren: true },
},
},
});
Generated SQL: where "$$tX"."childId" = "$$tY"."id"
even though $$tY (derived from Child with an ORDER BY clause) does not project the “id” column.
Environment (please complete the following information):
- ZenStack version: 3.9.2
- Database type: Postgresql
- Node.js/Bun version: 24.15.0
- Package manager: npm
Description and expected behavior
omit: { id: true } on an ordered nested relation drops the PK from the derived subquery, breaking further nested includes (column "$$tN"."id" does not exist)
Generated SQL: where "$$tX"."childId" = "$$tY"."id"
even though $$tY (derived from Child with an ORDER BY clause) does not project the “id” column.
Environment (please complete the following information):