Skip to content

Derived text-backed enum sources lose declaration ordering #30208

Description

@JoeRoddy

Related upstream issue prisma/orm#30163 was closed as completed for the direct PostgreSQL-native enum array_position(text[], enum) overload. This report is limited to the separately reproduced loss of value-set declaration order after a text-backed enum source becomes derived. The standalone package keeps both observations so a new published runtime can be checked completely.

Type: lowering/result semantics bug. Target: prisma/orm PostgreSQL renderer.

The standalone enum is declared low, high, medium. Its direct table query orders the two fixture rows low, high. Wrapping that table in a native DerivedTableSource, while selecting and ordering the same column, returns high, low. The derived query has fallen back to lexical order. The two native ASTs and both actual PostgreSQL results are in run.ts and results.json.

A separate rc.8 baseline case calls ordinary orderBy(e => e.state.asc()) and reproduces the incompatible array_position(text[], enum) overload. That defect is already covered and closed by #30163, so it is retained only as a versioned regression check and is not part of this proposed issue.

Expected behavior: a result-preserving derived SELECT should retain its output enum's declared ordering, including aliases. Relevant regression coverage includes root and nested ordering, ascending and descending order, null placement, output aliases, per-parent pagination, DISTINCT ON, and text-backed versus native enums.

Primary source: tagged PostgreSQL target, public AST types.

Environment

  • @prisma/orm-postgres: 8.0.0-rc.8 (the live latest tag when reverified September 6, 2026)
  • Prisma CLI: 8.0.0-rc.13
  • TypeScript: 5.9.3
  • Node: 26.5.0
  • npm: 11.17.0
  • OS: macOS 26.6.2 arm64
  • PostgreSQL: 14.23 for database-backed cases

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