Skip to content

TML-3501: The enum docs say members are written values that compare by their data type - #30798

Merged
wmadden merged 2 commits into
mainfrom
tml-enum-values-closeout
Oct 20, 2026
Merged

wmadden merged 2 commits into
mainfrom
tml-enum-values-closeout

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Docs only. This brings the enum docs in line with the code after #30790, which made enum members values of their data type.

One example from ADR 157 shows the change. It was written with quoted members on an integer codec:

enum Priority {
  @@type("pg/int8@1")
  Low  = "1"
  High = "10"
}

Since #30790, Low = "1" is refused with PSL_VALUE_TYPE_INCOMPATIBLE, because pg/int8 has no cast from text. The example now writes Low = 1 and High = 10. The stored contract and the CHECK are unchanged.

What changed

  • ADR 157 (October 12 amendment):
    • A PSL member is a written value, read by ADR 254's cast rule. MongoDB PSL does not use that rule yet.
    • has(), nameOf() and ordinalOf() find a value equal to a member by its data type's equalityKey, so 0.50 is the pg/numeric member 0.5.
    • A codec that sets keepsWrittenForm keeps the codec's type for the enum's members and columns.
    • The error codes for each refusal are listed per surface. The MongoDB refusal applies to managed collections only.
  • ADR 244: the untyped IN list compares members in the column's type, so a numeric column admits 0.50 for the member 0.5.
  • ADR 254:
    • The "reference" bullet says the member's own value was read by the cast rule.
    • CHECK constraints are no longer listed under "Not decided here".
    • The MongoDB refusal is stated for both TypeScript and PSL.
  • Data Contract and Contract Emitter & Types subsystems: the same points, where they describe enums.

How it was checked

  • Every changed sentence was checked against the source by two reviewers.
  • Each PSL example was loaded through the real Postgres stack in a temporary test, then deleted. The ADR 157 example produces the documented contract and check name.
  • pnpm lint:docs passes.

Found while checking

For a SQL enum member that is neither a string nor a finite number, PSL throws CONTRACT.ENUM_INVALID with no source position, instead of a diagnostic at the member. ADR 157 now says so. The code fix is TML-3653.

Agent: pimpernel-41

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified how enum members are read and written across SQL and MongoDB targets.
    • Documented enum casting, equality-based member matching, type narrowing, and preservation of written forms.
    • Expanded guidance for enum validation errors and managed collection constraints.
    • Clarified how enum and codec types are represented when literal rendering is unavailable.
    • Updated examples for numeric SQL enum values and NaN in list containment expressions.

…d keepsWrittenForm keeps the codec type

ADR 157 example writes int8 members unquoted, as the cast rule now requires. ADR 157, ADR 244, ADR 254 and the Data Contract and Contract Emitter subsystem docs now say how enum members are read from PSL, how equalityKey decides membership, and how keepsWrittenForm types enum fields.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…SL codes for each enum refusal

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric requested a review from a team as a code owner October 20, 2026 16:21
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: prisma/orm/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5fd2277b-1835-4ad3-acad-2d627948b367
📥 Commits

Reviewing files that changed from the base of the PR and between 720c295 and c95c70d.

📒 Files selected for processing: 5
  • docs/architecture docs/adrs/ADR 157 - Execution enums.md
  • docs/architecture docs/adrs/ADR 244 - Check constraints are opaque wire-named expressions.md
  • docs/architecture docs/adrs/ADR 254 - Data types and casts.md
  • docs/architecture docs/subsystems/1. Data Contract.md
  • docs/architecture docs/subsystems/2. Contract Emitter & Types.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The documentation updates describe enum casting and validation rules, equality-based enum matching, field type narrowing, and generated type behavior when codecs do not render literals. The examples also use numeric pg/int8@1 members and represent NaN as "NaN" in a containment expression.

Changes: Enum documentation

Layer / File(s) Summary
Enum casting and validation
docs/architecture docs/adrs/ADR 254 - Data types and casts.md, docs/architecture docs/adrs/ADR 157 - Execution enums.md
The ADRs describe enum member cast rules, SQL and MongoDB validation constraints, and related error behavior.
Enum execution and data contract
docs/architecture docs/adrs/ADR 157 - Execution enums.md, docs/architecture docs/subsystems/1. Data Contract.md
The documentation describes equality-based enum matching and field type narrowing. Examples use numeric pg/int8@1 members and "NaN" in a containment expression.
Generated type rules
docs/architecture docs/subsystems/2. Contract Emitter & Types.md
The type-generation description clarifies when enum and value-set literals use rendered literals or codec output types.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: wmadden

Merge Risk: ⚪ Minimal · up to c95c7

No actionable documentation or contract risk remains in this docs-only change.

Architecture risk: 🔵 Low · up to c95c7

The change affects 1 system.

Changed systems: docs

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — docs (service) was modified; 5 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in docs/architecture docs/adrs/ADR 157 - Execution enums.md: Domain enum member handling now applies ADR 254 cast rules for SQL PSL enums, rejecting incompatible textual pg/int8 values with PSL_VALUE_TYPE_INCOMPATIBLE; MongoDB retains codec-based JSON member reading.
  • observed — Modified behavior in docs/architecture docs/adrs/ADR 157 - Execution enums.md: Execution accessors now compare values using enum data-type equality, and emitted field types remain narrowed to enum members unless the codec preserves written forms, in which case the codec type is retained.
  • observed — Modified behavior in docs/architecture docs/adrs/ADR 157 - Execution enums.md: Codec validation now documents separate refusals for unsupported equality/enum codecs, managed SQL members that are not strings or finite numbers, and managed MongoDB BSON types unsupported by validators, with distinct TypeScript, PSL, and source-position error behavior.
  • observed — Modified behavior in docs/architecture docs/adrs/ADR 157 - Execution enums.md: The Priority example changes pg/int8@1 members from quoted strings to numeric literals.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the documentation change and accurately summarizes the updated enum member value and comparison semantics.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (5 skipped: 5 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma/orm-extension-arktype-json

npm i https://pkg.pr.new/@prisma/orm-extension-arktype-json@30798

@prisma/orm-extension-middleware-cache

npm i https://pkg.pr.new/@prisma/orm-extension-middleware-cache@30798

@prisma/orm-extension-paradedb

npm i https://pkg.pr.new/@prisma/orm-extension-paradedb@30798

@prisma/orm-extension-pgvector

npm i https://pkg.pr.new/@prisma/orm-extension-pgvector@30798

@prisma/orm-extension-postgis

npm i https://pkg.pr.new/@prisma/orm-extension-postgis@30798

@prisma/orm-extension-supabase

npm i https://pkg.pr.new/@prisma/orm-extension-supabase@30798

@prisma/orm-family-mongo

npm i https://pkg.pr.new/@prisma/orm-family-mongo@30798

@prisma/orm-family-sql

npm i https://pkg.pr.new/@prisma/orm-family-sql@30798

@prisma/orm-framework

npm i https://pkg.pr.new/@prisma/orm-framework@30798

@prisma/orm-mongo

npm i https://pkg.pr.new/@prisma/orm-mongo@30798

@prisma/orm-postgres

npm i https://pkg.pr.new/@prisma/orm-postgres@30798

@prisma/orm-sqlite

npm i https://pkg.pr.new/@prisma/orm-sqlite@30798

@prisma/orm-target-mongo

npm i https://pkg.pr.new/@prisma/orm-target-mongo@30798

@prisma/orm-target-postgres

npm i https://pkg.pr.new/@prisma/orm-target-postgres@30798

@prisma/orm-target-sqlite

npm i https://pkg.pr.new/@prisma/orm-target-sqlite@30798

@prisma/orm-toolchain

npm i https://pkg.pr.new/@prisma/orm-toolchain@30798

commit: c95c70d

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
postgres / no-emit 259.12 KB (0%)
postgres / emit 229.28 KB (0%)
mongo / no-emit 210.93 KB (0%)
mongo / emit 182.13 KB (0%)
cf-worker / no-emit 321.45 KB (0%)
cf-worker / emit 288.28 KB (0%)

@wmadden
wmadden added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit 595ac08 Oct 20, 2026
24 checks passed
@wmadden
wmadden deleted the tml-enum-values-closeout branch October 20, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants