Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

fix(emitter,sql-orm-client): apply mutation defaults - #272

Merged
aqrln merged 1 commit into
mainfrom
tml-2171-orm-client-create-doesnt-apply-execution-mutation-defaults
Mar 31, 2026
Merged

aqrln merged 1 commit into
mainfrom
tml-2171-orm-client-create-doesnt-apply-execution-mutation-defaults

Conversation

@aqrln

@aqrln aqrln commented Mar 31, 2026 •

Copy link
Copy Markdown
Member

Fixes https://linear.app/prisma-company/issue/TML-2171/orm-client-create-doesnt-apply-execution-mutation-defaults

The problem was in two places:

  1. Contract emitter lost the information about the mutation defaults.
  2. The run-time part of the mutation defaults logic wasn't implemented in sql-orm-client.

The type-level logic for fields with default was already in place but didn't work because the information was missing in the contract.

Summary by CodeRabbit

  • New Features

    • Automatic execution defaults (e.g., generated IDs) are now applied during create(), createAll(), createCount(), and upsert() and persisted when configured.
    • Generated contract types now include a readonly execution metadata field for richer type information.
  • Tests

    • Expanded unit and integration coverage for execution defaults, upsert behavior, and returning-capability scenarios.
  • Chores

    • Added a Tags model/table and new test helpers/fixtures to support defaults/upsert tests.

@coderabbitai

coderabbitai Bot commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 01d8a1a2-f46d-4696-847a-d61abcada041

📥 Commits

Reviewing files that changed from the base of the PR and between b96ccd0 and 92cf5e9.

⛔ Files ignored due to path filters (2)
  • packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.json is excluded by !**/generated/**
📒 Files selected for processing (12)
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/3-extensions/sql-orm-client/src/collection.ts
  • packages/3-extensions/sql-orm-client/src/mutation-executor.ts
  • packages/3-extensions/sql-orm-client/test/collection-contract.test.ts
  • packages/3-extensions/sql-orm-client/test/fixtures/contract.ts
  • packages/3-extensions/sql-orm-client/test/integration/create.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/delete.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/helpers.ts
  • packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts
  • packages/3-extensions/sql-orm-client/test/integration/update.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/upsert.test.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/3-extensions/sql-orm-client/test/integration/update.test.ts
  • packages/3-extensions/sql-orm-client/src/collection.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts
  • packages/3-extensions/sql-orm-client/test/integration/delete.test.ts
  • packages/3-extensions/sql-orm-client/test/fixtures/contract.ts
  • packages/3-extensions/sql-orm-client/test/integration/upsert.test.ts
  • packages/3-extensions/sql-orm-client/test/collection-contract.test.ts

📝 Walkthrough

Walkthrough

Emitter now emits a readonly execution property into generated ContractBase types. The SQL ORM client applies mutation defaults during create/upsert flows via the execution context; tests, fixtures, and schema setup were updated to cover default ID generation and returning-capability variations.

Changes

Cohort / File(s) Summary
Type Emitter
packages/2-sql/3-tooling/emitter/src/index.ts, packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
ContractBase generation now includes readonly execution: ... (serialized ir.execution). Tests added to assert emitted execution metadata and undefined when absent.
Mutation Defaults Application
packages/3-extensions/sql-orm-client/src/collection.ts, packages/3-extensions/sql-orm-client/src/mutation-executor.ts
Added applyCreateDefaults(...) helper and call sites; create/upsert flows invoke context.applyMutationDefaults to mutate mapped insert rows with returned defaults before compiling/executing inserts. insertSingleRow now receives ExecutionContext and derives contract from it.
Test Fixtures & Schema Setup
packages/3-extensions/sql-orm-client/test/fixtures/contract.ts, packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts, packages/3-extensions/sql-orm-client/test/integration/helpers.ts
Added tags table and Tag model to test contract; test schema now drops/creates tags; added helpers createUsersCollectionWithoutReturning and createReturningTagsCollection.
Integration & Unit Tests
packages/3-extensions/sql-orm-client/test/collection-contract.test.ts, packages/3-extensions/sql-orm-client/test/integration/create.test.ts, packages/3-extensions/sql-orm-client/test/integration/delete.test.ts, packages/3-extensions/sql-orm-client/test/integration/update.test.ts, packages/3-extensions/sql-orm-client/test/integration/upsert.test.ts
Updated tests to use collections without returning capability where applicable; added tests asserting auto-generated IDs, preservation of explicit IDs, createCount behavior, and upsert create-branch defaults with tags collection.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Collection
  participant ExecutionContext
  participant Compiler
  participant Database

  Client->>Collection: createAll(rows)
  Collection->>ExecutionContext: applyMutationDefaults({op: 'create', table, values})
  ExecutionContext-->>Collection: [{column, value}, ...]
  Collection->>Collection: merge defaults into mapped rows
  Collection->>Compiler: compile insert/insert-returning with mapped rows
  Compiler->>Database: execute insert
  Database-->>Compiler: inserted rows
  Compiler-->>Collection: result
  Collection-->>Client: return created rows
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 I nudged some defaults into each row,

Small IDs blossomed where none did grow,
Execution whispered into the type,
Tags hopped in and set things right,
A happy rabbit cheered the build tonight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(emitter,sql-orm-client): apply mutation defaults' accurately reflects the main changes: fixing the emitter to include mutation defaults in the contract and implementing mutation default application in the sql-orm-client.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tml-2171-orm-client-create-doesnt-apply-execution-mutation-defaults

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

@pkg-pr-new

pkg-pr-new Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/runtime-executor

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/runtime-executor@272

@prisma-next/mongo-core

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-core@272

@prisma-next/mongo-orm

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

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-runtime@272

@prisma-next/sql-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-runtime@272

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-paradedb@272

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-pgvector@272

@prisma-next/postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/postgres@272

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-orm-client@272

@prisma-next/target-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-mongo@272

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-mongo@272

@prisma-next/driver-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-mongo@272

@prisma-next/contract-authoring

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract-authoring@272

@prisma-next/contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract-ts@272

@prisma-next/ids

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ids@272

@prisma-next/psl-parser

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-parser@272

@prisma-next/psl-printer

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-printer@272

@prisma-next/cli

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/cli@272

@prisma-next/emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/emitter@272

@prisma-next/eslint-plugin

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/eslint-plugin@272

@prisma-next/migration-tools

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/migration-tools@272

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/vite-plugin-contract-emit@272

@prisma-next/sql-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract@272

@prisma-next/sql-errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-errors@272

@prisma-next/sql-operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-operations@272

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-schema-ir@272

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-psl@272

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-ts@272

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-emitter@272

@prisma-next/family-sql

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-sql@272

@prisma-next/sql-kysely-lane

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-kysely-lane@272

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-lane-query-builder@272

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-relational-core@272

@prisma-next/sql-builder-new

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-builder-new@272

@prisma-next/sql-lane

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-lane@272

@prisma-next/target-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-postgres@272

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-postgres@272

@prisma-next/driver-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-postgres@272

@prisma-next/core-control-plane

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/core-control-plane@272

@prisma-next/core-execution-plane

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/core-execution-plane@272

@prisma-next/config

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/config@272

@prisma-next/contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract@272

@prisma-next/operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/operations@272

@prisma-next/plan

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/plan@272

@prisma-next/utils

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/utils@272

commit: 92cf5e9

@aqrln
aqrln marked this pull request as ready for review March 31, 2026 14:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/3-extensions/sql-orm-client/src/collection.ts (1)

96-111: Consider sharing one mutation-default applier across collection and nested mutation paths.

applyCreateDefaults() here and the near-identical loop in packages/3-extensions/sql-orm-client/src/mutation-executor.ts now duplicate the same behavior. Extracting a shared pure helper would reduce drift risk between nested and non-nested create flows.

As per coding guidelines: "Extract pure helpers first when refactoring large monolithic files (helpers with no I/O and no global state)".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/3-extensions/sql-orm-client/src/collection.ts` around lines 96 -
111, applyCreateDefaults duplicates logic found in mutation-executor.ts; extract
a shared pure helper to apply mutation defaults and use it from both places.
Create a pure function (e.g., applyMutationDefaultsToRows) that accepts the
ctx.context (or specifically the applyMutationDefaults method), tableName, and
rows and performs the for-loop currently in applyCreateDefaults, then replace
the body of applyCreateDefaults and the similar loop in mutation-executor.ts to
call this new helper; reference the existing symbols applyCreateDefaults,
CollectionContext, SqlContract, SqlStorage, and the loop in mutation-executor.ts
to locate and replace the duplicated logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/3-extensions/sql-orm-client/src/collection.ts`:
- Around line 96-111: applyCreateDefaults duplicates logic found in
mutation-executor.ts; extract a shared pure helper to apply mutation defaults
and use it from both places. Create a pure function (e.g.,
applyMutationDefaultsToRows) that accepts the ctx.context (or specifically the
applyMutationDefaults method), tableName, and rows and performs the for-loop
currently in applyCreateDefaults, then replace the body of applyCreateDefaults
and the similar loop in mutation-executor.ts to call this new helper; reference
the existing symbols applyCreateDefaults, CollectionContext, SqlContract,
SqlStorage, and the loop in mutation-executor.ts to locate and replace the
duplicated logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 8b9b6b53-5fc1-43c6-a814-0a8969967f19

📥 Commits

Reviewing files that changed from the base of the PR and between b0409e1 and bcf866a.

⛔ Files ignored due to path filters (2)
  • packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.json is excluded by !**/generated/**
📒 Files selected for processing (12)
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/3-extensions/sql-orm-client/src/collection.ts
  • packages/3-extensions/sql-orm-client/src/mutation-executor.ts
  • packages/3-extensions/sql-orm-client/test/collection-contract.test.ts
  • packages/3-extensions/sql-orm-client/test/fixtures/contract.ts
  • packages/3-extensions/sql-orm-client/test/integration/create.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/delete.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/helpers.ts
  • packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts
  • packages/3-extensions/sql-orm-client/test/integration/update.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/upsert.test.ts

@wmadden wmadden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment, otherwise approved

@aqrln
aqrln force-pushed the tml-2171-orm-client-create-doesnt-apply-execution-mutation-defaults branch from bcf866a to b96ccd0 Compare March 31, 2026 15:25
Fixes https://linear.app/prisma-company/issue/TML-2171/orm-client-create-doesnt-apply-execution-mutation-defaults

The problem was in two places:

1. Contract emitter lost the information about the mutation defaults.
2. The run-time part of the mutation defaults logic wasn't implemented
   in `sql-orm-client`.

The type-level logic for fields with default was already in place but
didn't work because the information was missing in the contract.
@aqrln
aqrln force-pushed the tml-2171-orm-client-create-doesnt-apply-execution-mutation-defaults branch from b96ccd0 to 92cf5e9 Compare March 31, 2026 15:29

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/3-extensions/sql-orm-client/src/collection.ts (1)

632-633: Consider centralizing mutation-default application across mutation paths.

applyMutationDefaults is now orchestrated in both this file and mutation-executor.ts. To reduce drift risk, consider a single shared internal mutation-preparation helper used by create/createCount/upsert and nested mutation flows.

Also applies to: 663-664, 682-683

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/3-extensions/sql-orm-client/src/collection.ts` around lines 632 -
633, The codebase currently calls applyCreateDefaults from collection.ts and
applyMutationDefaults from mutation-executor.ts in parallel mutation paths
(create/createCount/upsert and nested flows), which risks drift; create a single
internal helper (e.g., prepareMutationDefaults or
centralizedApplyMutationDefaults) that accepts (ctx, tableName, mappedRows,
mutationType?) and encapsulates the logic currently in applyCreateDefaults and
applyMutationDefaults, replace direct calls to applyCreateDefaults in
collection.ts (where you currently call applyCreateDefaults(this.ctx,
this.tableName, mappedRows) and similar sites at the noted locations) and
replace the applyMutationDefaults usages in mutation-executor.ts to call the new
helper so all mutation paths (create, createCount, upsert, and nested includes)
share one implementation. Ensure the helper is exported/available to both
collection.ts and mutation-executor.ts and preserve existing parameters/return
shape so callers need minimal changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/3-extensions/sql-orm-client/src/collection.ts`:
- Around line 632-633: The codebase currently calls applyCreateDefaults from
collection.ts and applyMutationDefaults from mutation-executor.ts in parallel
mutation paths (create/createCount/upsert and nested flows), which risks drift;
create a single internal helper (e.g., prepareMutationDefaults or
centralizedApplyMutationDefaults) that accepts (ctx, tableName, mappedRows,
mutationType?) and encapsulates the logic currently in applyCreateDefaults and
applyMutationDefaults, replace direct calls to applyCreateDefaults in
collection.ts (where you currently call applyCreateDefaults(this.ctx,
this.tableName, mappedRows) and similar sites at the noted locations) and
replace the applyMutationDefaults usages in mutation-executor.ts to call the new
helper so all mutation paths (create, createCount, upsert, and nested includes)
share one implementation. Ensure the helper is exported/available to both
collection.ts and mutation-executor.ts and preserve existing parameters/return
shape so callers need minimal changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 3a062667-f469-4ec8-9f44-72ec9704e432

📥 Commits

Reviewing files that changed from the base of the PR and between bcf866a and b96ccd0.

⛔ Files ignored due to path filters (2)
  • packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.json is excluded by !**/generated/**
📒 Files selected for processing (12)
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/3-extensions/sql-orm-client/src/collection.ts
  • packages/3-extensions/sql-orm-client/src/mutation-executor.ts
  • packages/3-extensions/sql-orm-client/test/collection-contract.test.ts
  • packages/3-extensions/sql-orm-client/test/fixtures/contract.ts
  • packages/3-extensions/sql-orm-client/test/integration/create.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/delete.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/helpers.ts
  • packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts
  • packages/3-extensions/sql-orm-client/test/integration/update.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/upsert.test.ts
✅ Files skipped from review due to trivial changes (4)
  • packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts
  • packages/3-extensions/sql-orm-client/src/mutation-executor.ts
  • packages/3-extensions/sql-orm-client/test/integration/update.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/3-extensions/sql-orm-client/test/collection-contract.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/delete.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/helpers.ts
  • packages/3-extensions/sql-orm-client/test/integration/upsert.test.ts
  • packages/3-extensions/sql-orm-client/test/integration/create.test.ts

@aqrln
aqrln enabled auto-merge (squash) March 31, 2026 15:33
@aqrln
aqrln merged commit aa0bdb2 into main Mar 31, 2026
14 checks passed
@aqrln
aqrln deleted the tml-2171-orm-client-create-doesnt-apply-execution-mutation-defaults branch March 31, 2026 15:37
wmadden pushed a commit that referenced this pull request Apr 1, 2026
Fixes
https://linear.app/prisma-company/issue/TML-2171/orm-client-create-doesnt-apply-execution-mutation-defaults

The problem was in two places:

1. Contract emitter lost the information about the mutation defaults.
2. The run-time part of the mutation defaults logic wasn't implemented
in `sql-orm-client`.

The type-level logic for fields with default was already in place but
didn't work because the information was missing in the contract.

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

* **New Features**
* Automatic default value generation (e.g., IDs) is now applied during
create(), createAll(), createCount(), and upsert() and persisted when
configured.
* Generated contract types now include a readonly execution metadata
field for richer type information.

* **Tests**
* Expanded integration and unit coverage for execution defaults, upsert
behavior, and returning-capability scenarios.

* **Chores**
* Added a Tags model/table to test fixtures for upsert/defaults
scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
wmadden pushed a commit that referenced this pull request Apr 1, 2026
Fixes
https://linear.app/prisma-company/issue/TML-2171/orm-client-create-doesnt-apply-execution-mutation-defaults

The problem was in two places:

1. Contract emitter lost the information about the mutation defaults.
2. The run-time part of the mutation defaults logic wasn't implemented
in `sql-orm-client`.

The type-level logic for fields with default was already in place but
didn't work because the information was missing in the contract.

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

* **New Features**
* Automatic default value generation (e.g., IDs) is now applied during
create(), createAll(), createCount(), and upsert() and persisted when
configured.
* Generated contract types now include a readonly execution metadata
field for richer type information.

* **Tests**
* Expanded integration and unit coverage for execution defaults, upsert
behavior, and returning-capability scenarios.

* **Chores**
* Added a Tags model/table to test fixtures for upsert/defaults
scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
wmadden pushed a commit that referenced this pull request Apr 1, 2026
Fixes
https://linear.app/prisma-company/issue/TML-2171/orm-client-create-doesnt-apply-execution-mutation-defaults

The problem was in two places:

1. Contract emitter lost the information about the mutation defaults.
2. The run-time part of the mutation defaults logic wasn't implemented
in `sql-orm-client`.

The type-level logic for fields with default was already in place but
didn't work because the information was missing in the contract.

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

* **New Features**
* Automatic default value generation (e.g., IDs) is now applied during
create(), createAll(), createCount(), and upsert() and persisted when
configured.
* Generated contract types now include a readonly execution metadata
field for richer type information.

* **Tests**
* Expanded integration and unit coverage for execution defaults, upsert
behavior, and returning-capability scenarios.

* **Chores**
* Added a Tags model/table to test fixtures for upsert/defaults
scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
wmadden pushed a commit that referenced this pull request Apr 1, 2026
Fixes
https://linear.app/prisma-company/issue/TML-2171/orm-client-create-doesnt-apply-execution-mutation-defaults

The problem was in two places:

1. Contract emitter lost the information about the mutation defaults.
2. The run-time part of the mutation defaults logic wasn't implemented
in `sql-orm-client`.

The type-level logic for fields with default was already in place but
didn't work because the information was missing in the contract.

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

* **New Features**
* Automatic default value generation (e.g., IDs) is now applied during
create(), createAll(), createCount(), and upsert() and persisted when
configured.
* Generated contract types now include a readonly execution metadata
field for richer type information.

* **Tests**
* Expanded integration and unit coverage for execution defaults, upsert
behavior, and returning-capability scenarios.

* **Chores**
* Added a Tags model/table to test fixtures for upsert/defaults
scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
jkomyno pushed a commit that referenced this pull request Apr 1, 2026
Fixes
https://linear.app/prisma-company/issue/TML-2171/orm-client-create-doesnt-apply-execution-mutation-defaults

The problem was in two places:

1. Contract emitter lost the information about the mutation defaults.
2. The run-time part of the mutation defaults logic wasn't implemented
in `sql-orm-client`.

The type-level logic for fields with default was already in place but
didn't work because the information was missing in the contract.

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

* **New Features**
* Automatic default value generation (e.g., IDs) is now applied during
create(), createAll(), createCount(), and upsert() and persisted when
configured.
* Generated contract types now include a readonly execution metadata
field for richer type information.

* **Tests**
* Expanded integration and unit coverage for execution defaults, upsert
behavior, and returning-capability scenarios.

* **Chores**
* Added a Tags model/table to test fixtures for upsert/defaults
scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants