Skip to content

TML-3367: Attribute arguments declare the data type they receive - #30539

Merged
wmadden-electric merged 136 commits into
mainfrom
tml-3367-data-type-value
Oct 7, 2026
Merged

wmadden-electric merged 136 commits into
mainfrom
tml-3367-data-type-value

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

Refs TML-3367, the second slice of the Linear project SQL expression literals. Builds on #30534 (TML-3296) and targets its branch until that merges. The Linear project "Data types own column types" is waiting on this PR.

Summary

Prisma 8 decides whether a written value fits a column by data type: "8" is a pg/text value, 8 is a pg/int2 value, and a column accepts a value only if its type is that type or casts from it. Until now only @default applied that rule, and the code for it lived in the SQL family. This PR moves the rule into the framework and packages it as dataTypeValue, an argument type any attribute or block can use to say "I receive a value of type X". Nothing uses it yet; the next slice gives index predicates, check constraints and policies the type sql/expression, and another project types default-function arguments such as the 8 in nanoid(8).

Skill update

n/a. Schemas do not change. Three diagnostics move or reword, recorded in upgrade-instructions/pending/arguments-typed-by-data-type/: @default refusals point at the written value instead of the whole attribute, a call to a default function with wrong arguments reports what is wrong with the arguments instead of Expected one of: …, and a refused @default value says what to write instead of listing the column's casts.

At a glance

What a schema author sees. Before this PR, a wrong argument to a default function was reported at the whole value with a list of everything @default accepts:

model User {
  id String @id @default(nanoid("8"))
  //                     ^^^^^^^^^^^^  Expected one of: string | number | boolean | autoincrement() | …
}

After this PR the argument itself is typed, so the report lands on "8" and says what to write:

model User {
  id String @id @default(nanoid("8"))
  //                            ^^^  pg/int4 has no cast from pg/text; write a number
}

What the spec author writes to get that: one argument type in the attribute's spec, naming the data type the argument receives.

funcCall('nanoid', { positional: [dataTypeValue(dataTypeId('pg/int4'), ctx.dataTypes)] })

Given nanoid(8) it returns { type: 'pg/int4', value: 8, span }. In the next slice the same argument type, with sql/expression, turns where: "(archived_at IS NULL)" into a message that ends with the exact rewrite: sql/expression has no cast from pg/text; write it as sql`(archived_at IS NULL)` .

Decision

This PR ships five things.

  1. The cast rule for a single written value is framework code. readWrittenValue turns a literal into a typed value through the authoring entry registered for its syntax, and castTypedValue applies the ADR 254 cast rule. Both live in packages/1-framework/1-core/framework-components/src/shared/written-value.ts. The SQL family keeps only what is specific to @default: lists and the two default-only refusals.
  2. dataTypeValue(dataType, support) is an argument type in the attribute-spec combinator kit (ADR 231). The other combinators (str(), int(), entityRef(), funcCall()) describe PSL syntax, and their values are schema metadata such as an index name. dataTypeValue is for the positions whose value goes to the database: it reads any literal, types it by how it is written, runs the cast rule for the data type the position names, and returns the canonical value, its type id and the argument's span. Its refusals use the general diagnostic codes and point at the written value.
  3. The stack exposes its data types once, and every spec context carries them. ControlStack.dataTypes and ContractSourceContext.dataTypes hold the registered data types together with their authoring entries; the old dataTypeLookup field is gone. Every place that builds an attribute spec context passes that pair (ADR 249).
  4. One wording for a refused value. A refusal is the structured reason a written value is not admitted (an unknown tag, text the entry cannot read, no cast from the value's type), before any command words it as a diagnostic; the code has ReadRefusal and CastRefusal, and ADR 254 says a value is "refused by the cast rule". describeRefusal in the framework turns a refusal into its code and message, and both @default and dataTypeValue use it. @default(1.5) on an integer column and, later, nanoid(1.5) say the same thing: pg/int4 has no cast from pg/float8; write a number.
  5. oneOf keeps the diagnostics of the function the author named. When the argument is a call to a plain identifier and exactly one alternative is a funcCall of that name, oneOf returns that alternative's result as is. Without this, every function default's argument error would be swallowed by Expected one of: ….

How it fits together

  1. A written value has a data type of its own. ADR 254 gave every literal a type decided by how it is written: a quoted string is the target's text type, true its boolean type, a number the smallest numeric type that holds it, and a tagged literal such as json`{}` the type whose authoring entry owns the tag. A "written value" is the literal in that form, before any type is chosen. A "canonical value" is the JSON the type stores.
  2. A receiving position admits a value by the cast rule. The receiving type takes the value if it is that type, or if it declares a cast from the value's type. castTypedValue runs the cast and returns a value of the receiving type. Nothing else decides admission; there is no per-syntax special case.
  3. dataTypeValue applies steps 1 and 2 to one attribute argument. It reads the PSL expression as a written value (readWrittenScalar), types it (readWrittenValue), casts it (castTypedValue), and reports any refusal at the argument with a message that ends in what to write. Spec authors pass the data type id and the stack's data types; a stack that lacks the type still builds the spec, and only parse throws, so the language server can list attributes on any stack.
  4. Specs get the stack's data types from their context. AttributeSpecContext.dataTypes is set by the SQL and Mongo interpreters, the binder and the language server, all from the one pair the control stack builds. EMPTY_DATA_TYPES is the explicit value for a language-server source with no stack.
  5. @default now speaks the same language. It reads its scalar values through the framework functions and words its refusals through describeRefusal, so an author sees one message shape whether the value sits in @default(...) or in a typed argument.
  6. oneOf lets the argument's message through. Every @default function is one alternative of a oneOf. When the author names a function that exactly one alternative offers, that alternative's diagnostics are the answer, not Expected one of.

Reviewer notes

  • Largest diff: packages/2-sql/2-authoring/contract-psl/src/data-type-default.ts and psl-column-resolution.ts. Code moved out to the framework; what stayed is list handling, the default-only refusals, and the location prefix (Field "X.y": , Field "X.y" at element 2: ).
  • Widest diff: the switch from dataTypeLookup to dataTypes on ControlStack and ContractSourceContext touches about a hundred test files, most by one line.
  • User-visible message changes, all listed with before-and-after rows in the app upgrade fragment: @default(uuid(5)) now says Expected one of: 4 | 7 at 5; a refused @default value says write a number instead of it casts from pg/int2; a column type nothing writes is told to write sql`...`; a list element the column's list cast does not take names the element types it takes.
  • Spans: PSL_VALUE_TYPE_INCOMPATIBLE and PSL_INVALID_LITERAL from @default point at the written value or list element. The two default-only codes, PSL_DEFAULT_LIST_EXPECTED and PSL_INVALID_DEFAULT_LITERAL, still point at the attribute.
  • Naming: "body" is what is written between a tagged literal's quotes; "text" is the canonical value. TaggedLiteralCanonicalization.text, TaggedLiteralExprAst.text(), parseJsonText and checkSqlDefaultText follow that rule.
  • The binder requires dataTypes because it also builds spec contexts. createSqlBinder and createMongoBinder both take it.
  • Language server: LspControlStack.dataTypes comes from the control stack. Completion for a dataTypeValue argument returns nothing yet; the next slice adds it.
  • Three tests main added for date and time defaults expected PSL_INVALID_DEFAULT_LITERAL. A quoted date is read as text and the column type's cast refuses it, which TML-3296: sql is the tag of the SQL family's data type sql/expression #30534 reports as PSL_INVALID_LITERAL; the tests now expect that code.
  • Three tarball tests cannot run on the author's machine (pnpm install in their scratch project refuses @vercel/[email protected]). CI is the check for them.
  • Project files. projects/sql-expression-literals/ holds the spec, design, plan, review reports and status. It is transient and is deleted at project close-out.

Behavior changes & evidence

  • The cast rule for one written value is framework code. packages/1-framework/1-core/framework-components/src/shared/written-value.ts. Evidence: framework-components/test/written-value.test.ts (each written kind and refusal; a cast that changes the value; admittedTags order; describeAdmittedForms for a tag type, a boolean type, a number type reached through a classifier).
  • A PSL expression reads as a written scalar or says why not. packages/1-framework/2-authoring/psl-parser/src/written-scalar.ts. Evidence: psl-parser/test/written-scalar.test.ts, one case per expression kind.
  • dataTypeValue admits a literal by type and refuses at the value with the general codes. packages/1-framework/2-authoring/psl-parser/src/attribute-spec/combinators/data-type-value.ts. Evidence: psl-parser/test/attribute-spec-combinators.data-type-value.test.ts (every diagnostic with code, message and span; inside a funcCall that is an arm of oneOf; an unregistered type builds but does not parse), and test/integration/test/authoring/data-type-value.test.ts on the assembled Postgres and SQLite stacks.
  • oneOf routes a named call to its funcCall alternative. psl-parser/src/attribute-spec/combinators/one-of.ts. Evidence: the same combinator test file (nanoid("8") at "8"; other(1) still Expected one of; a dotted or colon-qualified callee falls through; two alternatives of one name fall through), and contract-psl/test/interpreter.defaults.functions.test.ts for cuid(), uuid(5) and nanoid(1).
  • The stack and every spec context carry dataTypes. framework-components/src/control/control-stack.ts, psl-parser/src/attribute-spec/spec-context.ts, binder.ts, language-server/src/lsp-control-stack.ts. Evidence: language-server/test/config-resolution.test.ts (passed through by identity), the Mongo contract-psl interpreter tests, psl-parser/test/binder.test.ts.
  • @default reads and words its values through the framework. contract-psl/src/data-type-default.ts, psl-column-resolution.ts. Evidence: contract-psl/test/interpreter.defaults.data-types.test.ts (whole messages and spans, including a vector column's list cast and an unknown tag inside a list) and the Prisma 7 defaults test.
  • Docs. ADR 231 (the combinator and the oneOf rule), ADR 249 (the context carries dataTypes), ADR 254 (the scalar cast rule is framework code; @default reports at the written value), docs/reference/error-reference.md, docs/reference/psl-editor-tooling-tagged-literals.md, docs/reference/codec-authoring-guide.md.

Compatibility / migration / risk

  • Contracts: no change. fixtures:check shows no contract.json change.
  • Schema authors: no schema changes. The message and span changes above each have a row in the app upgrade fragment.
  • Extension authors: ContractSourceContext.dataTypes replaces dataTypeLookup; ControlDefaultRegistries has no dataTypeEntries and a spec reads tags from ctx.dataTypes.entries; entryForTag, WrittenValue and DataTypeSupport moved to @internal/framework-components/authoring; TaggedLiteralCanonicalization.body is text; checkSqlDefaultBody and its neighbours are checkSqlDefaultText, reservedSqlDefaultText and UNSAFE_DEFAULT_TEXT; createBinder, createSqlBinder and createMongoBinder require dataTypes; oneOf routes a named call as described. The extension upgrade fragment has the full table.
  • Code that asserts PSL diagnostic spans or Expected one of text: see the app upgrade fragment.

Testing performed

On the final HEAD:

  • pnpm build, pnpm typecheck, pnpm lint, pnpm lint:deps, pnpm lint:casts (delta 0), pnpm lint:throws (delta 0), pnpm check:error-reference, pnpm lint:framework-vocabulary (272 of 272), pnpm fixtures:check (tree clean), pnpm check:upgrade-coverage --mode pr against the merge base
  • pnpm test:packages: 1425 files pass; the 3 tarball files fail on the registry refusal above; files that timed out under load pass alone
  • Targeted integration files (test/authoring/**, test/number-defaults/**, test/date-time-defaults/**, and the Mongo and value-object files whose imports changed). The full test:integration suite runs in CI.
  • Manual QA: the slice 2t script in projects/sql-expression-literals/manual-qa.md reads each changed diagnostic as a user would; the run is recorded there
  • Two rounds of architect and code review, reports in projects/sql-expression-literals/slice-reviews/2t/ and 2t-round-2/; every finding is fixed

Follow-ups

  • TML-3288: @@index, @@fullTextIndex, @@check and policy predicates take sql literals through dataTypeValue.
  • TML-3289: the TypeScript builder takes sql values.
  • The project "Data types own column types" types default-function arguments with dataTypeValue; a default-function signature will be built from the stack's data types, as recorded in that project's notes.

Alternatives considered

  • Leave the cast rule in the SQL family and have the parser call back into it. Rejected: the framework's combinators cannot import family code, and the rule is not SQL-specific.
  • A "tagged literal" parameter kind with its own error for plain strings. Rejected: it describes syntax, not types. The cast rule already refuses a value of another type, and one mechanism serves sql, json and any future tag.
  • Leave oneOf alone and forbid dataTypeValue as a direct arm of it. Rejected: every @default function is an arm of oneOf, so the argument's refusal would never reach the author. Routing a named call to its one funcCall alternative fixes that for every attribute.
  • Keep the old @default wording, it casts from pg/int2. Rejected: a list of cast source ids tells the author which types exist, not what to write; write a number does, and one wording serves both @default and typed arguments.
  • Make dataTypes optional on the spec context. Rejected: an absent value would silently disable the cast rule. The language server passes EMPTY_DATA_TYPES when it has no stack, which makes the case explicit.
  • Move list casts into the framework too. Rejected for this slice: only @default takes lists, and the six places the next slice types take scalars. ADR 254 records the split.

Checklist

  • All commits are signed off (git commit -s) per the DCO.
  • I read CONTRIBUTING.md and the change is scoped to one logical concern.
  • Tests are updated.
  • The PR title is in TML-NNNN: <sentence-case title> form.
  • The Skill update section above is filled in.

Notes for the reviewer

See Reviewer notes above.

Agent: charon-96

Summary by CodeRabbit

  • New Features
    • Attribute specifications can now validate values against their receiving data types, with clearer guidance when a value is incompatible.
  • Bug Fixes
    • Default-value diagnostics now point to the invalid value or list element and distinguish unsupported list casts from invalid element types.
    • Invalid arguments to uniquely matched function calls now receive focused diagnostics instead of a generic alternatives error.
  • Documentation
    • Updated authoring and upgrade guidance for literal validation, diagnostics, and default values.

Spec, design, plan, decisions, research and the status file for resuming
the work. Raw SQL in a schema is a value of the data type sql/expression.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…d literal printer

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…on data type slice

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
The cast rule already keeps the sql/expression entry out of literal defaults. Also corrects the wrapNamespaceBlock line reference in the design (F09).

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
The code now reports only a single value written on a list column, which is a refusal about shape, not about type.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
A cast and a list cast that throw are PSL_INVALID_LITERAL. Every refusal row now asserts its whole message.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
It reads the canonical value through sqlTextFromCanonical, as the six places in slice 2b will. The reserved-name message names the tag through SQL_EXPRESSION_TAG.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…s user

lowerTaggedLiteral lowered nothing any more, and its refusal had the type of a default-function result. The sql/expression code moves out of data-type-default.ts, which holds no per-type code.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
The sqlExpressionDataType doc comment points at ADR 254. sqlTextReadsBack moves to slice 2b, next to its caller. The authoring entry exports only printTaggedLiteral from tagged-literal; each other function is added in the slice that first imports it from there.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
The code comment, the entry documentation the editor shows, and ADR 254 said "SQL text", which would admit a statement or a query. The extensions doc no longer teaches a view query as a sql literal or describes the removed prefixed tags.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…nd text

ADR 129 is retitled "Tagged literals write values of data types" and no longer says a tag names the pack that owns the text. ADR 254 states the prefix rule once, by the owner of the data type, and ADR 129 and the index link to it. The body is what is written between the quotes; the text is the canonical value. ADR 254 now says @default reports its cast-rule codes at the attribute. The error reference drops "a list holding another list", which PSL cannot write.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
They used pg.sql and sqlite.sql, which no longer exist, as the example of a valid dotted tag.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
assertNothingCastsFromSqlExpression throws CONTRACT.DATA_TYPE_CASTS_FROM_SQL_EXPRESSION for a cast or a list cast from sql/expression. The family instance runs it on every data type the stack registers, so an extension cannot turn a sql literal into a value of another type. runtimeError is exported from the shared codec entry so shared-plane code can raise the same kind of error as stack assembly.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
For Postgres with every shipped extension pack, and for SQLite: the stack registers the family objects themselves, and no registered data type casts from sql/expression.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Deleting the adapter authoring tests removed the only tests of the Postgres and SQLite number classifiers, the boolean reader, and JSON and numeric read and print. The cases move to the targets, which own the entries; only the cases about lowering keys are dropped.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…oid's size is grammar

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… kind (TML-3367)

exactRewrite moves into framework-components, so @default offers it too: meta Jsonb @default("{}") now says Expected json`...`; write json`{}`. It is offered only when the receiving type would take the rewritten literal.

RefusalGuidance.forms holds WrittenForm values (kind, tag, phrase). The range rule compares kinds, not phrases. describeRefusedValueType words the no-cast rule for dataTypeValue, @default and the list-element arm, so no refusal is invented. describeExpected builds every Expected sentence; the not-a-literal refusal now reads Expected sql`...`; got an identifier.

dataTypeValue throws an InternalError for a registered type nothing writes. taggedLiteralTextReadsBack is renamed printedTaggedLiteralReadsBack, and printTaggedLiteral's doc states when its literal reads back.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…dataTypeValue word a refusal alike (TML-3367)

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…a-literal message (TML-3367)

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden-electric and others added 7 commits October 6, 2026 11:06
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
The binder's argument matching, new on main for hover, gains the dataTypeValue case: an argument typed by a data type matches when it is a literal.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden
wmadden added this pull request to the merge queue Oct 7, 2026
@wmadden
wmadden removed this pull request from the merge queue due to a manual request Oct 7, 2026
The rc.15 release moved upgrade fragments that this branch had edited into upgrade-instructions/releases/; those keep the text rc.15 shipped. The arguments-typed-by-data-type fragment now describes the change from rc.15: DefaultMappingOptions had dataTypeLookup, the JSON helpers lived in @internal/sql-contract/data-type-support, and the enum member and list element messages rc.15 documents.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric added this pull request to the merge queue Oct 7, 2026
Merged via the queue into main with commit b35bcd7 Oct 7, 2026
24 checks passed
@wmadden-electric
wmadden-electric deleted the tml-3367-data-type-value branch October 7, 2026 09:47
wmadden-electric added a commit that referenced this pull request Oct 7, 2026
…h guides and add it to the notes

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden pushed a commit that referenced this pull request Oct 7, 2026
`8.0.0-rc.15` → `8.0.0-rc.16`

The peer dependency of `@prisma/orm-toolchain`, in
`packages/9-public/@prisma/orm-toolchain/package.json`:

```diff
-    "@prisma/cli-engine": "0.6.2",
+    "@prisma/cli-engine": "0.6.3",
```

## Why this release

Engine 0.6.3 fixes `prisma orm init` and `prisma contract emit` failing
on a valid contract with Bun. Engine 0.6.2 required ArkType `2.2.3`
exactly while the ORM packages accept `^2.2.2`, so an install could hold
two ArkType copies. Engine 0.6.3 accepts `^2.2.7`
([prisma/prisma-cli#332](prisma/prisma-cli#332)).

The Prisma CLI can only ship engine 0.6.3 once every product it mounts
peers exactly 0.6.3: its conformance check refuses a mismatch. Composer
0.27.0 already peers 0.6.3. ORM rc.15 still peers 0.6.2, so the next
Composer and CLI releases wait on this one.

## What this PR holds

- Every `@prisma/cli-engine` pin in the repository moves from `0.6.2` to
`0.6.3`.
- The lockfile is deduplicated so the workspace resolves one ArkType
copy, `2.2.7`. With two copies, the config-loader declaration build
fails with `TS2742`. The dedupe also drops seven duplicate copies of
build tools whose other versions were already in the lockfile; it adds
no new package version. The size-limit report shows bundles about 0.2%
larger, from ArkType 2.2.7.
- [#30539](#30539), merged
to `main` after this branch was cut, is merged in and released here: its
`@default` diagnostics change and its extension API renames.
- Upgrade guides for this hop, assembled from two fragments,
`engine-pin-moves-to-0-6-3` and `arguments-typed-by-data-type`:
[app](skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md)
and
[extension](skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md).
- The version bump, and the release notes in
[`docs/releases/v8.0.0-rc.16.md`](docs/releases/v8.0.0-rc.16.md).

## Checks run locally

- `pnpm build`, and the package tests of the CLI and the config loader.
- `pnpm test:packages`: one test timed out under machine load and passes
alone. Three tarball tests could not install on this machine because its
package manager refuses `@vercel/[email protected]`, which this PR does
not change; CI runs them.
- One CLI integration test, and `check:upgrade-coverage --mode publish`
against `v8.0.0-rc.15`.

Merging this PR ships the release: the push to `main` carries the bumped
root `version`, the `Publish to npm` workflow publishes `8.0.0-rc.16`
under `latest`, and a GitHub Release marked pre-release is created from
the notes file. See [`docs/oss/versioning.md`](docs/oss/versioning.md).
After it publishes, Composer and then the Prisma CLI release against it.

Agent: grendel-61

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Prisma 8.0.0-rc.16 updates extension APIs for working with data types
and tagged-literal text. Extension authors should review the migration
guidance for compatibility changes.
* **Bug Fixes**
* Bun commands that validate contracts now avoid failures caused by
multiple ArkType copies.
* **Improvements**
* `@default` diagnostics have updated locations and messages, including
more relevant suggestions for list elements.
* Prisma 8.0.0-rc.16 requires CLI engine 0.6.3; projects with a direct
engine pin should update it.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden-electric added a commit that referenced this pull request Oct 7, 2026
main holds slice 2t as the squash of #30539; where main's file equals the 2t branch tip, this branch's version is kept. The copy of the arguments-typed-by-data-type fragment goes: rc.16 released it. Two places adopt this branch's shapes: completion handles dataTypeValue with the tagged literals, and readStoredValue's refusal carries no place.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-prisma__orm that referenced this pull request Oct 12, 2026
## At a glance

The SQL expression literals project is finished. Raw SQL is one value
everywhere:

```prisma
@@check(expression: sql`
  owner_id > 0
    AND char_length(email) > 0
`, name: "profile_valid")
```

```ts
check({ expression: sql`owner_id > 0 AND char_length(email) > 0`, name: 'profile_valid' });
```

```ts
// generated migration.ts
checkExpression('profile_valid_5901ae2d', sql`owner_id > 0 AND char_length(email) > 0`)
```

This PR closes the project: it deletes
`projects/sql-expression-literals/`, after moving the decisions that
lived only there into ADR 268, and records two lessons from the project
in the team's Drive calibration.

## Decision

The project's transient files go. What must outlive them now lives in
ADRs, the subsystem docs, Drive calibration and Linear:

- **ADR 268** gains four alternatives that were recorded only in the
project's design notes: holding opaque SQL in DDL as the query AST's
`RawExpr`, migration functions that take only `sql` values, leaving
generated migration files on strings, and a public builder for `sql`
values from computed strings. Its status line now lists `sql` values in
generated migration files as built.
- **`drive/calibration/failure-modes.md`** gains F47 (a stack of PRs
outlives its base's squash merge, and the last PR passes 250 commits,
which the DCO check cannot read) and F48 (a new committed contract
fixture fails the planner golden test, which only the merge queue runs).
**`drive/calibration/dod.md`** adds the planner golden step to the slice
gate before queueing.
- **`projects/data-types-completion/design-notes.md`** pointed at this
project's design file; it now points at ADR 231, ADR 254 and TML-3367.

## Where each project decision lives

| Decision (project design notes) | Durable home |
| --- | --- |
| Every place that holds raw SQL takes a `sql` literal | ADR 268, ADR
129 |
| Plain strings are refused | ADR 268 |
| A `sql` literal is a value of the data type `sql/expression`; only
`@default` checks the text | ADR 268, ADR 254, ADR 129 |
| The SQL family defines and registers `sql/expression` (the notes'
first version said each target registers it; the family does) | ADR 268,
ADR 254 |
| The only tag is `sql` | ADR 268, ADR 129 |
| Specs name the data type an argument receives (`dataTypeValue`) | ADR
231, ADR 249, ADR 262 |
| The TypeScript builder takes `sql` values | ADR 268, ADR 129 |
| `contract infer` prints `sql` literals, and skips or notes text that
would not read back | ADR 129, ADR 268 |
| Opaque SQL is its own DDL value, `OpaqueSql` | Migration System
subsystem doc, "Opaque SQL in DDL"; ADR 268 (alternative) |
| Migration files write `sql` values when they read back unchanged | ADR
195 ("Recorded exception"), ADR 268, Migration System doc |
| Wire names keep line breaks in bodies with `--` | ADR 234 |
| One set of codes for cast-rule refusals | ADR 268, ADR 254 |
| The decision gets its own ADR | ADR 268 |
| The typed argument ships first, for the "Data types own column types"
project | Delivered as TML-3367; the default-function argument work is
TML-3389 |
| Grammar versus database values | ADR 231 |

## Project definition of done

- **Delivered:** all seven slices merged.

  | Slice | PR | Linear |
  | --- | --- | --- |
  | 2a | prisma#30534 | TML-3296 |
  | 2t | prisma#30539 | TML-3367 |
  | 1 | prisma#30546 | TML-3287 |
  | 4 | prisma#30554 | TML-3290 |
  | 2b | prisma#30550 | TML-3288 |
  | 3 | prisma#30558 | TML-3289 |
  | 5 | prisma#30677 | TML-3297 |

  Every Linear issue is Done.
- **Review and manual QA:** every slice that changed what a user sees
had design and code reviews, a fixes check, and a manual QA run.
- **Follow-ups filed:**
- TML-3554: two Postgres migration operations paste raw SQL into DDL as
strings.
  - TML-3555: a raw SQL column default cannot hold a `--` comment.

A gap found in QA, `now() - interval '1 day'` failing apply's default
check, is on TML-2362, which replaces that comparison. Two deferred
items need no ticket:
- `contract infer` and defaults that do not read back: slice 3 decided
and built it.
- A builder for `sql` values from computed strings: recorded in ADR 268
as not offered.
- **References:** nothing outside the deleted folder points into it.

## Testing performed

- `pnpm lint:docs`, `pnpm lint:legacy-name` and `pnpm
check:upgrade-coverage --mode pr` pass.
- This PR changes only docs, Drive calibration and the deleted project
folder.

## Linked issue

Closes out the Linear project [SQL expression
literals](https://linear.app/prisma-company/project/sql-expression-literals-c8a6659e7f4c)
(TML-3282).

## Skill update

n/a — docs and project files only.

## Checklist

- [x] All commits are signed off (`git commit -s`) per the
[DCO](../CONTRIBUTING.md#developer-certificate-of-origin-dco).
- [x] I read [CONTRIBUTING.md](../CONTRIBUTING.md) and the change is
scoped to one logical concern.
- [x] Tests are updated (n/a, docs only).
- [x] The PR title is in `TML-NNNN: <sentence-case title>` form.
- [x] The **Skill update** section above is filled in.

## Alternatives considered

- **Keep the project folder as a record.** Rejected: its spec, plan,
design and status describe a project that no longer exists, and the
decisions worth keeping now live in ADRs.
- **Move the design notes into `docs/` as they are.** Rejected: they are
a log written during the project, and each decision now has an ADR or
subsystem-doc home.

Agent: lagertha-65

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Clarified how migration functions and generated migration files
represent SQL, including how DDL is stored and the limits on creating
SQL values from computed strings.
* Updated slice planning guidance to require running the planner golden
test in write mode and reviewing recorded DDL when committed contract
manifests change.
* Added guidance for handling stacked pull requests that exceed the DCO
commit limit and contract-fixture changes that fail merge-queue golden
tests.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
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.

3 participants