Skip to content

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) #2830

Description

@ludovicmotte

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions