Skip to content

TML-3789: On PostgreSQL, Json(storage: jsonb) gives a jsonb column, Json still gives json, and sql.String(n) is now sql.Varchar(n) - #31065

Merged
wmadden merged 12 commits into
mainfrom
tml-3789-postgres-json-convenience
Nov 17, 2026
Merged

wmadden merged 12 commits into
mainfrom
tml-3789-postgres-json-convenience

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
model Event {
  id      Int    @id
  payload Json                  // a json column, as before
  search  Json(storage: jsonb)  // a jsonb column
  code    sql.Varchar(12)       // was sql.String(12)
}

What changes for a user

Json is a convenience type on PostgreSQL. It has one option, storage:

Written Explicit type Column
Json or Json(storage: json) PlainJson json
Json(storage: jsonb) Jsonb jsonb
  • No schema, contract or database changes. A field written Json keeps its json column. pnpm fixtures:check shows no difference.
  • contract infer and contract print write a json column as Json and a jsonb column as Json(storage: jsonb). They wrote Jsonb before. Jsonb remains valid.
  • The Prisma 7 reader writes Prisma 7's Json, which was jsonb, as Json(storage: jsonb), and Json @db.Json as Json.
  • In a TypeScript contract, type.Json() and type.Json({ storage: 'jsonb' }) are typed as the explicit type they choose. The column helper jsonColumn is renamed plainJsonColumn, with no alias.
  • The reference docs say what a json column cannot do (equality filters, indexes, unique constraints) and that Json(storage: jsonb) can. A new integration test shows the index and unique limits against PostgreSQL.

sql.String(n) is renamed sql.Varchar(n) on PostgreSQL, SQLite and MySQL. sql.String stays for one release line as a deprecated alias: in PSL it warns PSL_DEPRECATED_SCALAR_NAME and emits the same contract; in TypeScript it still compiles.

Both renames have upgrade instructions with detection patterns in upgrade-instructions/pending/postgres-json-convenience-type/.

Why

  • Json defaults to json. Json is the exact name of a PostgreSQL type, so it must not mean a different one. A user who wants jsonb says so.
  • PlainJson exists because a convenience type and an explicit type cannot share a name. A type choice names its explicit type in the same namespace. Users meet PlainJson in hover text, the type reference, and the refusal of @db.Json. The tools never write it.
  • sql.String shared a name with the String convenience type and meant something else (a varchar(n) column). The namespace is now sql.Varchar(n) and sql.Char(n).

ADRs

Also in this pull request

projects/scalar-convenience-types/spec.md and plan.md hold the design for the rest of the project: the same eight convenience types on MongoDB, SQLite and MySQL, each in a later pull request.

Verification

  • /drive-code-review (system design and code passes), two rounds; the second is clean on the pushed tip, with all acceptance criteria for this change passing.
  • Manual QA with the real CLI against a local PostgreSQL: emit, refusals, db init, contract infer, contract print round-trip, db verify, a TypeScript contract, and the Prisma 7 reader.
  • No source file under packages/1-framework changes.

Known gaps, tracked separately

  • Json @unique or an index on a Json field fails only when the migration runs, with PostgreSQL's own message, which does not mention Json(storage: jsonb). TML-3833 covers a clear error.
  • The TypeScript compiler suggests jsonbColumn for the removed jsonColumn. The upgrade instruction names the right replacement.

Alternatives considered

  • Default Json to jsonb. Built in TML-3789: PostgreSQL Json stores jsonb by default, and Json(storage: json) keeps a json column #30966 and closed: it changed every existing Json column and made a PostgreSQL type name mean another type.
  • No convenience type for Json. Leaves no way to say "a JSON value" and choose its storage, which every other scalar now has.
  • Name the explicit type JsonJson, by the value-suffix rule. It says nothing.
  • Rename sql.String inside the SQLite pull request. PostgreSQL is the released target it affects, so it ships here.

Closes TML-3789.

Agent: genghis-36

Summary by CodeRabbit

  • New Features

    • PostgreSQL Json now supports json storage by default and jsonb via an explicit storage option. The explicit json type is named PlainJson.
    • Variable-length SQL text types are now named sql.Varchar; sql.String remains available as a deprecated alias.
    • The PostgreSQL untyped JSON column helper is now named plainJsonColumn.
  • Documentation

    • Updated reference materials and migration guidance to explain the new names, storage choices, and JSON limitations, including unsupported equality filtering, indexing, and unique constraints for json.

…PostgreSQL and the other targets

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…decs it lacks

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…here shared codec code goes

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… for every target

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…chitect and principal engineer design reviews

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… scalar convenience types ADR

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… PlainJson, a json column, by default, or Jsonb

A bare Json still gives pg/json@1, so no schema or contract changes. The json type's explicit name is PlainJson, the tools write a jsonb column as Json(storage: jsonb), jsonColumn is renamed plainJsonColumn with an upgrade instruction, and ADR 316, ADR 257 and ADR 279 record the naming rule and its PlainJson exception.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… every SQL target, and sql.String stays as a deprecated alias that warns in PSL

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…eSQL now and on the other targets when they get these convenience types, and define PlainJson as the explicit type a bare Json becomes

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…index on a json column, and the upgrade detections find re-exported, namespaced and multi-line uses

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 November 17, 2026 07:44
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds PostgreSQL Json storage selection, renames the explicit PostgreSQL json type and raw column helper, and adds sql.Varchar with deprecated sql.String compatibility. It updates authoring, inference, adapters, tests, reference documentation, and migration guidance.

Changes: Scalar naming and PostgreSQL JSON

Layer / File(s) Summary
Varchar constructor and alias
packages/2-sql-family/9-family/*, packages/3-targets/{mysql,postgres,sqlite}/..., packages/2-sql-family/2-authoring/...
The SQL family exposes sql.Varchar; sql.String remains as a deprecated alias. Target tests cover warnings, contract equivalence, and length validation.
PostgreSQL JSON mapping and adoption
packages/3-targets/postgres/..., packages/2-sql-family/2-authoring/..., packages/3-extensions/supabase/src/contract/contract.prisma, test/integration/test/*
PlainJson names the explicit PostgreSQL json type. Json defaults to json and accepts storage: jsonb to select Jsonb. Authoring presets, schema declarations, and tests use these forms.
Reference and migration material
docs/reference/*, docs/architecture docs/*, skills/prisma-8/references/*, upgrade-instructions/pending/postgres-json-convenience-type/*
References describe JSON storage behavior and scalar naming. Migration instructions and detection tests cover the renamed helper and scalar constructor.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Schema as PostgreSQL schema
  participant Json as Json convenience type
  participant ExplicitType as PlainJson or Jsonb
  Schema->>Json: declare storage choice
  Json->>ExplicitType: select type for json or jsonb
Loading

Suggested reviewers: sevinf, tensordreams

Merge Risk: Minimal · up to 573b7

This change adds PostgreSQL Json(storage: jsonb) selection, renames the explicit json type to PlainJson, and adds sql.Varchar with a deprecated sql.String alias. Existing contracts keep their json columns. No merge-blocking risk remains after review.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main changes: PostgreSQL Json(storage: jsonb) maps to a jsonb column, Json still maps to json, and sql.String(n) is renamed to sql.Varchar(n). The raw summary covers the same chang…
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: Title check

Explanation

The title names the main changes: PostgreSQL Json(storage: jsonb) maps to a jsonb column, Json still maps to json, and sql.String(n) is renamed to sql.Varchar(n). The raw summary covers the same changes across ADRs, type constructors, the Prisma 7 reader, tests, and docs. The title is long (130 characters, 18 words) but it is specific and matches the changeset.

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
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: prisma/orm
  • Branch: main
  • File: .coderabbit.yml
  • Commit: cfb20d5
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 63a0880c-a754-425e-8052-0f07f4537583
Commits

Reviewing files that changed from the base of the PR and between cfb20d5 and 573b769.

Files ignored due to path filters: 2

  • projects/scalar-convenience-types/plan.md is excluded by !projects/**
  • projects/scalar-convenience-types/spec.md is excluded by !projects/**
Files selected for processing: 70

  • docs/architecture docs/ADR-INDEX.md
  • docs/architecture docs/adrs/ADR 170 - Pack-provided type constructors and field presets.md
  • docs/architecture docs/adrs/ADR 254 - Data types and casts.md
  • docs/architecture docs/adrs/ADR 257 - Scalar types are named after the target on every surface.md
  • docs/architecture docs/adrs/ADR 279 - Convenience types choose an explicit type from their arguments.md
  • docs/architecture docs/adrs/ADR 312 - A Postgres extension is a contract entity, and db sign refuses a space with unmet invariants.md
  • docs/architecture docs/adrs/ADR 316 - PostgreSQL scalars get convenience types.md
  • docs/architecture docs/adrs/ADR 321 - An extension pack's extension is found through the connection's search_path.md
  • docs/reference/error-reference.md
  • docs/reference/scalar-types.md
  • packages/2-sql-family/2-authoring/contract-psl/README.md
  • packages/2-sql-family/2-authoring/contract-psl/src/removed-field-presets.ts
  • packages/2-sql-family/2-authoring/contract-psl/test/interpreter.diagnostics.test.ts
  • packages/2-sql-family/2-authoring/contract-psl/test/interpreter.extensions.test.ts
  • packages/2-sql-family/2-authoring/contract-psl/test/interpreter.removed-field-presets.test.ts
  • packages/2-sql-family/2-authoring/contract-ts/src/refuse-types-key.ts
  • packages/2-sql-family/2-authoring/contract-ts/src/removed-field-presets.ts
  • packages/2-sql-family/2-authoring/contract-ts/test/contract-dsl.alias-constants.test.ts
  • packages/2-sql-family/2-authoring/contract-ts/test/removed-field-presets.test.ts
  • packages/2-sql-family/9-family/README.md
  • packages/2-sql-family/9-family/src/core/authoring-types.ts
  • packages/2-sql-family/9-family/test/pack.authoring.test.ts
  • packages/3-extensions/arktype-json/README.md
  • packages/3-extensions/supabase/src/contract/contract.prisma
  • packages/3-targets/mysql/1-mysql/1-target/src/core/type-constructors.ts
  • packages/3-targets/mysql/1-mysql/9-facade/test/sql-varchar.test.ts
  • packages/3-targets/postgres/1-target/README.md
  • packages/3-targets/postgres/1-target/src/core/migrations/postgres-migration.ts
  • packages/3-targets/postgres/1-target/src/core/migrations/resolve-ddl-schema.ts
  • packages/3-targets/postgres/1-target/src/core/type-constructors.ts
  • packages/3-targets/postgres/1-target/test/prisma7-type-map.test.ts
  • packages/3-targets/postgres/1-target/test/psl-infer/infer-column-types.test.ts
  • packages/3-targets/postgres/1-target/test/psl-infer/infer-parse-emit.test.ts
  • packages/3-targets/postgres/1-target/test/psl-infer/inferred-psl/inferred-psl.defaults-and-types.test.ts
  • packages/3-targets/postgres/1-target/test/psl-infer/inferred-psl/inferred-psl.literal-defaults.test.ts
  • packages/3-targets/postgres/1-target/test/psl-print/convenience-types.test.ts
  • packages/3-targets/postgres/1-target/test/type-choice-inferred-marks.test.ts
  • packages/3-targets/postgres/1-target/test/type-constructors.test.ts
  • packages/3-targets/postgres/2-adapter/README.md
  • packages/3-targets/postgres/2-adapter/src/exports/column-types.ts
  • packages/3-targets/postgres/9-facade/test/contract-builder/namespace-keys.test.ts
  • packages/3-targets/postgres/9-facade/test/contract-builder/row-types.test-d.ts
  • packages/3-targets/postgres/9-facade/test/contract-builder/scalar-convenience-types.test-d.ts
  • packages/3-targets/postgres/9-facade/test/contract-builder/type-helpers.test-d.ts
  • packages/3-targets/postgres/9-facade/test/scalar-convenience-type-helpers.test.ts
  • packages/3-targets/postgres/9-facade/test/scalar-type-parity.test.ts
  • packages/3-targets/postgres/9-facade/test/sql-varchar.test.ts
  • packages/3-targets/sqlite/1-target/test/type-constructors.test.ts
  • packages/3-targets/sqlite/9-facade/test/contract-builder/row-types.test-d.ts
  • packages/3-targets/sqlite/9-facade/test/sql-string-length.test.ts
  • packages/3-targets/sqlite/9-facade/test/sql-varchar.test.ts
  • skills/prisma-8/references/contract.md
  • skills/prisma-8/references/quickstart.md
  • test/e2e/framework/test/fixtures/contract.ts
  • test/integration/test/authoring/generator-column-length.test.ts
  • test/integration/test/authoring/lsp-postgres-convenience-types.test.ts
  • test/integration/test/authoring/parity/ts-psl-parity.real-packs.test.ts
  • test/integration/test/authoring/parity/ts-psl-parity.value-arguments.test.ts
  • test/integration/test/authoring/preset-replacements/preset-replacement-rows.ts
  • test/integration/test/cli-journeys/defaults-read-by-codec.e2e.test.ts
  • test/integration/test/cli-journeys/infer-roundtrip-fidelity.prisma7-defaults.e2e.test.ts
  • test/integration/test/convenience-scalar-types/convenience-scalar-types.integration.test.ts
  • test/integration/test/convenience-scalar-types/json-index-limits.integration.test.ts
  • test/integration/test/date-time-defaults/defaults-read-by-codec.sqlite.e2e.test.ts
  • test/integration/test/planner-golden/fixtures/postgres/contract.ts
  • test/integration/test/psl-infer/convenience-scalar-types-infer.integration.test.ts
  • test/integration/test/psl-print/prisma7-convenience-types-print.integration.test.ts
  • test/integration/test/upgrade-instructions/postgres-json-convenience-type/detection.test.ts
  • upgrade-instructions/pending/postgres-json-convenience-type/app/instructions.md
  • upgrade-instructions/pending/postgres-json-convenience-type/extension/instructions.md
Files with no reviewable changes: 1

  • packages/3-targets/sqlite/9-facade/test/sql-string-length.test.ts

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

@wmadden
wmadden enabled auto-merge November 17, 2026 07:47
@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma/orm-extension-arktype-json

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

@prisma/orm-extension-middleware-cache

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

@prisma/orm-extension-paradedb

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

@prisma/orm-extension-pgvector

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

@prisma/orm-extension-postgis

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

@prisma/orm-extension-supabase

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

@prisma/orm-family-mongo

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

@prisma/orm-family-sql

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

@prisma/orm-framework

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

@prisma/orm-mariadb

npm i https://pkg.pr.new/@prisma/orm-mariadb@31065

@prisma/orm-mongo

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

@prisma/orm-mysql

npm i https://pkg.pr.new/@prisma/orm-mysql@31065

@prisma/orm-postgres

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

@prisma/orm-postgres-contrib

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

@prisma/orm-sqlite

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

@prisma/orm-target-mariadb

npm i https://pkg.pr.new/@prisma/orm-target-mariadb@31065

@prisma/orm-target-mongo

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

@prisma/orm-target-mysql

npm i https://pkg.pr.new/@prisma/orm-target-mysql@31065

@prisma/orm-target-postgres

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

@prisma/orm-target-sqlite

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

@prisma/orm-toolchain

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

commit: 573b769

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
postgres / no-emit 290.03 KB (+0.05% 🔺)
postgres / emit 254 KB (+0.06% 🔺)
mongo / no-emit 237.01 KB (0%)
mongo / emit 192.67 KB (0%)
cf-worker / no-emit 352.96 KB (+0.05% 🔺)
cf-worker / emit 312.66 KB (+0.05% 🔺)

@wmadden
wmadden added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit ac137d3 Nov 17, 2026
25 checks passed
@wmadden
wmadden deleted the tml-3789-postgres-json-convenience branch November 17, 2026 08:19
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-prisma__orm that referenced this pull request Nov 18, 2026
…, Boolean, Bytes and Json as convenience types, and Int64 is now Int64BigInt (prisma#31067)

```prisma
model Event {
  id      ObjectId @id @Map("_id")
  visits  Int                  // exactly Int32
  total   BigInt               // exactly Int64BigInt, read as a bigint
  count   BigInt(as: number)   // exactly Int64Number, read as a number
  price   Decimal              // exactly Decimal128
  name    String               // exactly BsonString
  payload Json                 // exactly PlainJson
}
```

## What changes for a user

**MongoDB gets the eight scalar convenience types PostgreSQL has.** Each
chooses one explicit type, and the contract stores only that explicit
type.

| Convenience type | `as` | `storage` | Becomes | Codec |
| --- | --- | --- | --- | --- |
| `Int` | | `int` | `Int32` | `mongo/int32@1` |
| `BigInt` | `bigint` (default) | `long` | `Int64BigInt` |
`mongo/int64@1` |
| | `number` | `long` | `Int64Number` | `mongo/int64Number@1` |
| `Float` | | `double` | `Double` | `mongo/double@1` |
| `Decimal` | | `decimal` | `Decimal128` | `mongo/decimal128@1` |
| `Boolean` | | `bool` | `Bool` | `mongo/bool@1` |
| `Bytes` | | `binData` | `Binary` | `mongo/binary@1` |
| `String` | | `string` | `BsonString` | `mongo/string@1` |
| `Json` | | `bson` | `PlainJson` | `mongo/json@1` |

- **No contract changes.** `pnpm fixtures:check` shows no difference. A
schema written with the convenience types and one written with the
explicit types emit byte-identical contracts.
- **`Int`, `Float` and `Boolean` no longer warn.** They were deprecated
aliases of `Int32`, `Double` and `Bool`. They are now the names a user
is meant to write.
- **Three explicit types are renamed,** because a convenience type and
an explicit type cannot share a name:
- `Int64` is now `Int64BigInt`. In PSL, `Int64` stays for one release
line as a deprecated alias that warns and emits the same contract. In a
TypeScript contract, `type.Int64()` is removed: it fails to compile, and
from untyped code it throws an error that says to write
`type.Int64BigInt()`.
- The explicit `String` is now `BsonString` and the explicit `Json` is
now `PlainJson`. A schema that writes `String` or `Json` is unaffected:
the convenience types give the same codecs.
- **The deprecation warning fires wherever a deprecated name is
written:** with or without parentheses, in a field, a value object
member, or the base of a `types {}` alias. Before, it fired only for a
bare name in a field. This matches the SQL family.
- **A mistyped type name** gets a message that lists the names a user is
meant to write, convenience types first.
- `storage: bson` on `Json` means "whichever BSON value fits". It is not
the explicit type `Bson`, which accepts any BSON value.

Upgrade instructions with detection patterns are in
`upgrade-instructions/pending/mongodb-scalar-convenience-types/`.

## Why

A convenience name must mean the same concept on every target.
PostgreSQL got these eight in prisma#30942 and prisma#31065; this is the same design
on MongoDB, declared with the existing type-choice mechanism. Nothing
under `packages/1-framework` changes except one test's expected values.

## ADRs

- **ADR 322 (new):** each target declares the scalar convenience types
over its own explicit types. It records the rules shared by every target
and MongoDB's table. SQLite's and MySQL's tables are added when those
targets get the types.
- ADR 257, ADR 279 and ADR 316 are amended to match.

## Verification

- `/drive-code-review` (system design and code passes), two rounds. The
second found two documentation gaps, fixed in the last commit; every
acceptance criterion that applies to MongoDB passes.
- Manual QA with the real CLI against a local MongoDB: emit, refusals,
deprecation warnings, a TypeScript contract, `db init`, a write and read
of every type with the stored BSON types checked, `db verify`, and the
three MongoDB examples.

## Notes for the reviewer

- The MongoDB deprecation warner is a second copy of the SQL family's
(`deprecated-type-names.ts` in each interpreter). A shared home would be
the framework, which this project does not change. A follow-up is
recorded in the plan.
- When `type.Int64()` fails to compile, TypeScript suggests `Int`, which
is the 32-bit type. The runtime error and the upgrade instruction name
the right replacement.
- The examples now write `Int` and `Float` where they wrote `Int32` and
`Double`. Their contracts are unchanged.

## Alternatives considered

- **Keep `type.Int64()` as a deprecated TypeScript helper,** as the SQL
builder does for its deprecated names. The MongoDB builder gives a
deprecated name no helper (ADR 257). A TypeScript rename fails at
compile time, and the upgrade instruction fixes it.
- **Leave `Int64` unsuffixed.** BSON's `long` has two codecs, so both
carry the value they read, as PostgreSQL's `Int8BigInt` and `Int8Number`
do.
- **A JSON string storage for `Json`.** It needs a new codec and is not
part of this change.

Part of TML-3790 (SQLite and MySQL follow in their own pull requests).

Agent: genghis-36


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

## Summary by CodeRabbit

* **New Features**
* MongoDB schemas now support scalar convenience types such as `Int`,
`BigInt`, `Float`, `Decimal`, `Boolean`, `Bytes`, `String`, and `Json`,
with options for choosing storage and value representation.
* Explicit scalar names now include `Int64BigInt`, `BsonString`, and
`PlainJson`. `Int64` remains available as a deprecated alias for
`Int64BigInt`.
* **Documentation**
* Added upgrade guidance for MongoDB scalar names and TypeScript
helpers. The TypeScript `type.Int64()` helper is no longer available.
* Clarified how convenience types map to explicit types and BSON
storage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Thegreatsura pushed a commit to Thegreatsura/prisma that referenced this pull request Nov 20, 2026
This closes the project that made `Int`, `BigInt`, `Float`, `Decimal`,
`String`, `Boolean`, `Bytes` and `Json` convenience types on every
target:

```prisma
model Product {
  id     Int     @id
  price  Decimal(precision: 10, scale: 2)
  stock  BigInt(as: number)
  data   Json
}
```

The same model now emits on PostgreSQL, MongoDB, SQLite, MySQL and
MariaDB. All five slices are merged. This pull request changes no code.
It has three commits:

1. The measurements of MySQL 8.4 and MariaDB 10.11 that the MySQL types
rest on move from the project spec to
`docs/reference/mysql-mariadb-scalar-column-behaviour.md`, linked from
ADR 322 and the docs index.
2. The final retro goes into `drive/retro/README.md`, and two checks it
produced go into `drive/calibration/dod.md`.
3. `projects/scalar-convenience-types/` is deleted.

Refs TML-3715.

## Slices

| Slice | Pull request |
| --- | --- |
| PostgreSQL `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean`,
`Bytes` | prisma#30942 |
| PostgreSQL `Json`, and `sql.Varchar` | prisma#31065 |
| MongoDB | prisma#31067 |
| SQLite | prisma#31086 |
| MySQL and MariaDB | prisma#31109 |

Every review thread on all five is resolved (1, 0, 3, 3 and 8 threads).

## Acceptance criteria

| Criterion | Result | Evidence |
| --- | --- | --- |
| Each row of each target's table resolves to its explicit type in PSL
and in a TypeScript contract | Met | `scalar-convenience-types.test.ts`
in the PostgreSQL, SQLite and MySQL target packages and in the SQLite
and MongoDB facades; `convenience-scalar-types.test.ts` in the MySQL
facade; `interpreter.type-choices.test.ts` in the MongoDB PSL package |
| A schema written with convenience types and one written with explicit
types emit the same `contract.json` | Met | The same test files compare
the two emitted contracts |
| Existing fixtures and examples emit byte-identical `contract.json`,
except SQLite `Decimal` and `BigIntNumber` | Met | `pnpm fixtures:check`
passed in every slice's CI and on the last branch after merging `main`;
the SQLite exceptions have an upgrade instruction and a CLI journey test
|
| PostgreSQL `contract infer` and `contract print` write the convenience
calls; other targets test each explicit type's convenience call | Met |
`psl-print/convenience-types.test.ts`,
`type-choice-inferred-marks.test.ts`, the print round-trip tests in the
merge queue; the per-target test files above |
| Each removed explicit name is a deprecated alias that warns, except
SQLite `BigIntNumber`; MongoDB `Int`, `Float`, `Boolean` no longer warn
| Met | `interpreter.deprecated-type-names.test.ts` (SQL) and the
MongoDB interpreter's deprecation tests |
| PostgreSQL `Json` behaves as specified | Met | prisma#31065:
`scalar-convenience-type-helpers.test.ts`, the infer and Prisma 7 reader
tests |
| Each stated limit of `json` is checked before it is documented | Met |
prisma#31065 |
| `check:upgrade-coverage`, `lint:ratchets` and `lint:deps` pass in
every slice | Met | CI on each slice; run again on this branch |
| Every rename a user must act on has an upgrade instruction with a
detection pattern | Met |
`upgrade-instructions/pending/postgres-json-convenience-type`,
`mongodb-scalar-convenience-types`, `sqlite-scalar-convenience-types`,
`mysql-scalar-convenience-types`, each with a `detection.test.ts` |
| `docs/reference/scalar-types.md` and the ADRs describe the final names
| Met | ADR 316, ADR 322, ADR 257, ADR 314 |
| No source file under `packages/1-framework` changes | Met | No slice
changed a file under `packages/1-framework/**/src/` |

One row of the MySQL table was deferred with a ticket: `Float(storage:
float)`, because a `float` column reads back rounded to six significant
digits.

## Where the spec's decisions live

The spec had decision sections. Each decision is in an ADR:

| Decision | Home |
| --- | --- |
| The shared rules for convenience and explicit names, and the
exceptions (`PlainJson`, `BsonString`, `IntegerBoolean`) | ADR 316, ADR
322, ADR 257 |
| PostgreSQL `Json` keeps meaning a `json` column; `sql.String` becomes
`sql.Varchar` | ADR 316 |
| MongoDB's table; `Int`, `Float`, `Boolean` stop warning | ADR 322, ADR
257 |
| SQLite's table; `Decimal` and `Boolean` get their own data types; the
driver reads every integer exactly | ADR 322 |
| The nine MySQL decisions (decimal parameters are cast, `Float` is
`double` only, `Bool` refuses values other than 0 and 1, `Json` has no
equality, MariaDB's JSON is read from its check, expression defaults,
decimals read as printed, bytes as base64 in an include, `binary`
defaults kept as reported) | ADR 322, MySQL section |
| Value logic shared by targets lives in
`@internal/type-implementations` | ADR 314 |
| The measurements behind the MySQL decisions |
`docs/reference/mysql-mariadb-scalar-column-behaviour.md` (this pull
request) |

## Files in the project folder

| File | Classification |
| --- | --- |
| `spec.md` | Transient, deleted. Its decisions are mapped above; its
measurements are migrated, with the sentences that described the code
before the change removed. |
| `plan.md` | Transient, deleted. |

No file outside the folder referred to it, before or after.

## Follow-ups

- TML-3898: the deprecated-name warner exists in both the SQL and
MongoDB PSL interpreters. One copy needs a framework change.
- TML-3892: `Decimal(precision: 10)` without a `scale` is refused on
MySQL and means scale 0 on PostgreSQL.
- TML-3896, the list of what MySQL and MariaDB need beyond a proof of
concept, gains the gaps found in the MySQL slice. It already held the
missing `Float(storage: float)` and the late failure of keys on `Bytes`,
`Json` and text columns.
- TML-3887, error messages in internal terms, gains two instances: a
refused write names the codec and not the field, and an include's decode
error is wrapped twice.
- TML-3833 (clearer errors where a PostgreSQL `json` field hits a limit)
and TML-3778 (PostgreSQL and SQLite `Json` codecs accept a value that is
not plain JSON) were filed earlier.

## Checked on this branch

`pnpm lint:docs` and `pnpm check:upgrade-coverage --mode pr` pass. `pnpm
build`, `pnpm typecheck`, `pnpm fixtures:check`, `pnpm lint:ratchets`
and `pnpm lint:deps` passed on the last slice after merging `main`, and
this branch adds only Markdown to that commit.

Agent: genghis-36


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

## Summary by CodeRabbit

* **Documentation**
* Added measured reference material on scalar-column behavior in MySQL
8.4 and MariaDB 10.11, covering reads, writes, defaults, metadata,
comparisons, JSON, aggregates, and server differences.
* Updated database and architecture references to link to the
measurements; the guide notes that its Prisma ORM mapping recollection
was not verified against documentation.
* Clarified validation checklists for package coverage, confirming
checks match the latest commit, and searching for affected integration
tests when message text changes.
* Added a retrospective entry covering merge-queue timing, testing,
coverage, recorded rulings, ticket scope, and review lessons.
<!-- 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.

2 participants