Skip to content

[Product Gap] Export collision-free, parser-validated Prisma identifiers #898

Description

@seonghobae

Buyer-visible problem

The current Prisma exporter converts database names to [A-Za-z][A-Za-z0-9_]* by character replacement and a leading prefix. That bounded sanitization can still create invalid or ambiguous artifacts:

  • Prisma's complete reserved-name set is not represented by a reviewed, versioned contract;
  • case variants and future Prisma grammar changes can drift from a hand-maintained list;
  • different database names can collapse to the same generated model or field name;
  • a valid source name such as M_model can collide with a prefixed fallback for another source name;
  • source PostgreSQL identifiers are not preserved through @map / @@map;
  • generated output is not passed through the supported Prisma parser/formatter as release evidence.

PR #894 deliberately removes an incomplete four-word workaround and retains only its independent relation-index performance change.

Product contract

Implement a dedicated identifier allocator for Prisma export that:

  1. derives the accepted grammar and reserved names from a pinned, supported Prisma toolchain rather than an ad hoc partial list;
  2. allocates deterministic, collision-free model, scalar-field, relation-field, enum, and relation names in their applicable namespaces;
  3. preserves original database table and column names through @@map and @map whenever a generated identifier differs;
  4. keeps quoted, multilingual, punctuation-bearing, case-sensitive, and long PostgreSQL identifiers traceable;
  5. records every source→generated mapping in an export manifest;
  6. fails closed if a deterministic unique name cannot be allocated within configured resource bounds;
  7. validates the complete generated schema with the pinned Prisma parser/formatter in CI;
  8. produces a fixed, non-reflecting UI failure while retaining a downloadable diagnostic manifest for authorized users.

Required regressions

  • model, Model, MODEL, and every reserved name from the pinned toolchain;
  • model versus M_model;
  • punctuation and whitespace collisions such as order-item, order item, and order_item;
  • table/field names beginning with digits;
  • Korean, Japanese, emoji, composed/decomposed Unicode, and quoted mixed-case PostgreSQL names;
  • two relations that sanitize to the same display name;
  • deterministic output under input reordering;
  • parser/formatter acceptance and source-name round trip through @map / @@map;
  • large-schema allocation bound and collision diagnostics.

Evidence and doctoring

Use the current Prisma Schema API as the primary authority for identifier syntax, reserved names, @map, and @@map. Record the exact Prisma version, grammar/tool SHA or package integrity, algorithm, collision policy, monitoring, rollback, and known limitations in docs/doctoring/ and CHANGELOG.md.

Merge gate

Production statement and branch coverage 100%, exact-head frontend suite/typecheck/build, pinned parser validation, no unresolved security/review finding, and qualifying independent approval.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: accessibilityAccessibility and assistive-technology supportarea: authAuthentication, authorization, identity, or tenant isolationarea: ci-cdCI, GitHub Actions, checks, release, or supply chainarea: securitySecurity boundary, hardening, or vulnerability preventionenhancementNew feature or requestpriority: mediumNormal-priority or P2 workscope: product-gapCustomer-visible product gapstatus: triagedOpen issue has an organization taxonomy assignmenttype: featureNew or expanded product capability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions