Repository navigation
TML-3367: Attribute arguments declare the data type they receive - #30539
Merged
Merged
Conversation
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]>
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]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…emoved Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…odes 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]>
…type slice 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]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…stack 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]>
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]>
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]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden
approved these changes
Oct 6, 2026
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]>
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
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]>
5 tasks done
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 apg/textvalue,8is apg/int2value, and a column accepts a value only if its type is that type or casts from it. Until now only@defaultapplied that rule, and the code for it lived in the SQL family. This PR moves the rule into the framework and packages it asdataTypeValue, 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 typesql/expression, and another project types default-function arguments such as the8innanoid(8).Skill update
n/a. Schemas do not change. Three diagnostics move or reword, recorded in
upgrade-instructions/pending/arguments-typed-by-data-type/:@defaultrefusals 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 ofExpected one of: …, and a refused@defaultvalue 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
@defaultaccepts:After this PR the argument itself is typed, so the report lands on
"8"and says what to write:What the spec author writes to get that: one argument type in the attribute's spec, naming the data type the argument receives.
Given
nanoid(8)it returns{ type: 'pg/int4', value: 8, span }. In the next slice the same argument type, withsql/expression, turnswhere: "(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.
readWrittenValueturns a literal into a typed value through the authoring entry registered for its syntax, andcastTypedValueapplies the ADR 254 cast rule. Both live inpackages/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.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.dataTypeValueis 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.ControlStack.dataTypesandContractSourceContext.dataTypeshold the registered data types together with their authoring entries; the olddataTypeLookupfield is gone. Every place that builds an attribute spec context passes that pair (ADR 249).ReadRefusalandCastRefusal, and ADR 254 says a value is "refused by the cast rule".describeRefusalin the framework turns a refusal into its code and message, and both@defaultanddataTypeValueuse 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.oneOfkeeps the diagnostics of the function the author named. When the argument is a call to a plain identifier and exactly one alternative is afuncCallof that name,oneOfreturns that alternative's result as is. Without this, every function default's argument error would be swallowed byExpected one of: ….How it fits together
trueits boolean type, a number the smallest numeric type that holds it, and a tagged literal such asjson`{}`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.castTypedValueruns the cast and returns a value of the receiving type. Nothing else decides admission; there is no per-syntax special case.dataTypeValueapplies 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 onlyparsethrows, so the language server can list attributes on any stack.AttributeSpecContext.dataTypesis set by the SQL and Mongo interpreters, the binder and the language server, all from the one pair the control stack builds.EMPTY_DATA_TYPESis the explicit value for a language-server source with no stack.@defaultnow speaks the same language. It reads its scalar values through the framework functions and words its refusals throughdescribeRefusal, so an author sees one message shape whether the value sits in@default(...)or in a typed argument.oneOflets the argument's message through. Every@defaultfunction is one alternative of aoneOf. When the author names a function that exactly one alternative offers, that alternative's diagnostics are the answer, notExpected one of.Reviewer notes
packages/2-sql/2-authoring/contract-psl/src/data-type-default.tsandpsl-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:).dataTypeLookuptodataTypesonControlStackandContractSourceContexttouches about a hundred test files, most by one line.@default(uuid(5))now saysExpected one of: 4 | 7at5; a refused@defaultvalue sayswrite a numberinstead ofit casts from pg/int2; a column type nothing writes is told to writesql`...`; a list element the column's list cast does not take names the element types it takes.PSL_VALUE_TYPE_INCOMPATIBLEandPSL_INVALID_LITERALfrom@defaultpoint at the written value or list element. The two default-only codes,PSL_DEFAULT_LIST_EXPECTEDandPSL_INVALID_DEFAULT_LITERAL, still point at the attribute.TaggedLiteralCanonicalization.text,TaggedLiteralExprAst.text(),parseJsonTextandcheckSqlDefaultTextfollow that rule.dataTypesbecause it also builds spec contexts.createSqlBinderandcreateMongoBinderboth take it.LspControlStack.dataTypescomes from the control stack. Completion for adataTypeValueargument returns nothing yet; the next slice adds it.mainadded for date and time defaults expectedPSL_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 asPSL_INVALID_LITERAL; the tests now expect that code.pnpm installin their scratch project refuses@vercel/[email protected]). CI is the check for them.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
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;admittedTagsorder;describeAdmittedFormsfor a tag type, a boolean type, a number type reached through a classifier).packages/1-framework/2-authoring/psl-parser/src/written-scalar.ts. Evidence:psl-parser/test/written-scalar.test.ts, one case per expression kind.dataTypeValueadmits 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 afuncCallthat is an arm ofoneOf; an unregistered type builds but does not parse), andtest/integration/test/authoring/data-type-value.test.tson the assembled Postgres and SQLite stacks.oneOfroutes a named call to itsfuncCallalternative.psl-parser/src/attribute-spec/combinators/one-of.ts. Evidence: the same combinator test file (nanoid("8")at"8";other(1)stillExpected one of; a dotted or colon-qualified callee falls through; two alternatives of one name fall through), andcontract-psl/test/interpreter.defaults.functions.test.tsforcuid(),uuid(5)andnanoid(1).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 Mongocontract-pslinterpreter tests,psl-parser/test/binder.test.ts.@defaultreads 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.oneOfrule), ADR 249 (the context carriesdataTypes), ADR 254 (the scalar cast rule is framework code;@defaultreports 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
fixtures:checkshows nocontract.jsonchange.ContractSourceContext.dataTypesreplacesdataTypeLookup;ControlDefaultRegistrieshas nodataTypeEntriesand a spec reads tags fromctx.dataTypes.entries;entryForTag,WrittenValueandDataTypeSupportmoved to@internal/framework-components/authoring;TaggedLiteralCanonicalization.bodyistext;checkSqlDefaultBodyand its neighbours arecheckSqlDefaultText,reservedSqlDefaultTextandUNSAFE_DEFAULT_TEXT;createBinder,createSqlBinderandcreateMongoBinderrequiredataTypes;oneOfroutes a named call as described. The extension upgrade fragment has the full table.Expected one oftext: 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 pragainst the merge basepnpm test:packages: 1425 files pass; the 3 tarball files fail on the registry refusal above; files that timed out under load pass alonetest/authoring/**,test/number-defaults/**,test/date-time-defaults/**, and the Mongo and value-object files whose imports changed). The fulltest:integrationsuite runs in CI.projects/sql-expression-literals/manual-qa.mdreads each changed diagnostic as a user would; the run is recorded thereprojects/sql-expression-literals/slice-reviews/2t/and2t-round-2/; every finding is fixedFollow-ups
@@index,@@fullTextIndex,@@checkand policy predicates takesqlliterals throughdataTypeValue.sqlvalues.dataTypeValue; a default-function signature will be built from the stack's data types, as recorded in that project's notes.Alternatives considered
sql,jsonand any future tag.oneOfalone and forbiddataTypeValueas a direct arm of it. Rejected: every@defaultfunction is an arm ofoneOf, so the argument's refusal would never reach the author. Routing a named call to its onefuncCallalternative fixes that for every attribute.@defaultwording,it casts from pg/int2. Rejected: a list of cast source ids tells the author which types exist, not what to write;write a numberdoes, and one wording serves both@defaultand typed arguments.dataTypesoptional on the spec context. Rejected: an absent value would silently disable the cast rule. The language server passesEMPTY_DATA_TYPESwhen it has no stack, which makes the case explicit.@defaulttakes lists, and the six places the next slice types take scalars. ADR 254 records the split.Checklist
git commit -s) per the DCO.TML-NNNN: <sentence-case title>form.Notes for the reviewer
See Reviewer notes above.
Agent: charon-96
Summary by CodeRabbit