Skip to content

contract emit: @map column names containing a space produce invalid contract.d.ts (unquoted property key) #981

Description

@SevInf

Summary

Emitting a contract whose model has a field mapped (via @map) to a physical column name containing a space produces an invalid contract.d.ts: the space-containing column is emitted as an unquoted TypeScript property key, e.g. readonly has space: { ... }, which is a syntax error. Emission then fails with PN-CLI-4999 ("Property or signature expected.").

Reproduction

PSL:

model DataRow {
  id          Int     @id
  spacedValue String? @map("has space")
  @@map("data_rows")
}

Run prisma-next contract emit against this schema.

Observed generated type (excerpt) — note the unquoted key has space:

readonly has space: { readonly nativeType: 'text'; readonly codecId: 'pg/text@1'; readonly nullable: true }

Emit fails:

PN-CLI-4999 Unexpected error
why: Property or signature expected. (38:1203)

Expected

Column names that are not valid bare TS identifiers (spaces, punctuation, etc.) must be emitted as quoted/bracketed property keys, e.g. readonly "has space": { ... }, so the generated contract.d.ts is valid TypeScript. Postgres permits such identifiers as quoted names, and @map accepts them at the authoring layer without validation.

Impact

Blocks authoring any contract that maps a column to a name containing a space (or other non-identifier characters). Discovered while building a PSL data-types fixture for test porting; ledger entry #118 (column name with a space) is parked on this issue.

Provenance

Found during test-porting work (tests-ports.md, entry #118). Related upstream coverage: Prisma client issues/22098-column_does_not_exist and column-name handling tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions