Package and version
prisma@8.0.0-rc.13 @prisma/orm-postgres@8.0.0-rc.8
What happened?
When specifying an index with a sort direction in contract.prisma using the familiar Prisma schema syntax:
@@index([created_at(sort: Desc)])
prisma contract emit fails during contract resolution with:
✘ [CONTRACT.SOURCE_LOAD_FAILED] Failed to resolve contract source
why: PSL to SQL contract interpretation failed
code: "PSL_INVALID_ATTRIBUTE_SYNTAX"
message: "Expected a field name"
In @prisma/orm-family-sql / @prisma/orm-framework (psl-parser.mjs), indexModelSpec parses positional fields with list(fieldRef("self")), which strictly expects bare IdentifierAst tokens. Because created_at(sort: Desc) is parsed as a FunctionCallAst, it fails with Expected a field name.
What did you expect to happen?
Either:
(sort: Desc) and (sort: Asc) field annotations inside @@index([ ... ]) should be supported in Prisma 8 PSL (parity with Prisma 7), OR
- If explicit sort direction in field lists is intentionally unsupported, the parser should provide a descriptive diagnostic (e.g. "Sort options are not supported inside field lists; use expression: ... instead") rather than the cryptic "Expected a field name" error.
Minimal reproduction
- Create a minimal
contract.prisma:
model Item {
id Uuid @id @default(uuid(7))
created_at TimestamptzString @default(now())
@@index([created_at(sort: Desc)])
@@map("items")
}
- Run:
Environment
- Node: v24.20.0
- OS: Linux x86_64
- Package manager: pnpm
- Database: Postgres (@prisma/orm-postgres)
Additional context
Running prisma contract emit --json produces the following structured error:
{
"code": "CONTRACT.SOURCE_LOAD_FAILED",
"summary": "Failed to resolve contract source",
"why": "PSL to SQL contract interpretation failed",
"meta": {
"diagnostics": [
{
"code": "PSL_INVALID_ATTRIBUTE_SYNTAX",
"message": "Expected a field name",
"sourceId": "./src/prisma/contract/contract.prisma"
}
]
}
}
Current workarounds:
- Use standard single-column index:
@@index([created_at])
- Use SQL expression:
@@index(expression: "created_at DESC", name: "items_created_at_desc_idx")
Package and version
prisma@8.0.0-rc.13 @prisma/orm-postgres@8.0.0-rc.8
What happened?
When specifying an index with a sort direction in
contract.prismausing the familiar Prisma schema syntax:@@index([created_at(sort: Desc)])prisma contract emitfails during contract resolution with:In
@prisma/orm-family-sql/@prisma/orm-framework(psl-parser.mjs),indexModelSpecparses positional fields withlist(fieldRef("self")), which strictly expects bareIdentifierAsttokens. Becausecreated_at(sort: Desc)is parsed as aFunctionCallAst, it fails withExpected a field name.What did you expect to happen?
Either:
(sort: Desc)and(sort: Asc)field annotations inside@@index([ ... ])should be supported in Prisma 8 PSL (parity with Prisma 7), ORMinimal reproduction
contract.prisma:Environment
Additional context
Running
prisma contract emit --jsonproduces the following structured error:{ "code": "CONTRACT.SOURCE_LOAD_FAILED", "summary": "Failed to resolve contract source", "why": "PSL to SQL contract interpretation failed", "meta": { "diagnostics": [ { "code": "PSL_INVALID_ATTRIBUTE_SYNTAX", "message": "Expected a field name", "sourceId": "./src/prisma/contract/contract.prisma" } ] } }Current workarounds:
@@index([created_at])@@index(expression: "created_at DESC", name: "items_created_at_desc_idx")