Repository navigation
Conversation
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (12)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughEmitter now emits a Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
@prisma-next/runtime-executor
@prisma-next/mongo-core
@prisma-next/mongo-orm
@prisma-next/mongo-runtime
@prisma-next/sql-runtime
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract-authoring
@prisma-next/contract-ts
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/emitter
@prisma-next/eslint-plugin
@prisma-next/migration-tools
@prisma-next/vite-plugin-contract-emit
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/family-sql
@prisma-next/sql-kysely-lane
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder-new
@prisma-next/sql-lane
@prisma-next/target-postgres
@prisma-next/adapter-postgres
@prisma-next/driver-postgres
@prisma-next/core-control-plane
@prisma-next/core-execution-plane
@prisma-next/config
@prisma-next/contract
@prisma-next/operations
@prisma-next/plan
@prisma-next/utils
commit: |
There was a problem hiding this comment.
🧹 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 inpackages/3-extensions/sql-orm-client/src/mutation-executor.tsnow 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
⛔ Files ignored due to path filters (2)
packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.tsis excluded by!**/generated/**packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.jsonis excluded by!**/generated/**
📒 Files selected for processing (12)
packages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/3-extensions/sql-orm-client/src/collection.tspackages/3-extensions/sql-orm-client/src/mutation-executor.tspackages/3-extensions/sql-orm-client/test/collection-contract.test.tspackages/3-extensions/sql-orm-client/test/fixtures/contract.tspackages/3-extensions/sql-orm-client/test/integration/create.test.tspackages/3-extensions/sql-orm-client/test/integration/delete.test.tspackages/3-extensions/sql-orm-client/test/integration/helpers.tspackages/3-extensions/sql-orm-client/test/integration/runtime-helpers.tspackages/3-extensions/sql-orm-client/test/integration/update.test.tspackages/3-extensions/sql-orm-client/test/integration/upsert.test.ts
wmadden
left a comment
There was a problem hiding this comment.
One small comment, otherwise approved
bcf866a to
b96ccd0
Compare
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.
b96ccd0 to
92cf5e9
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/3-extensions/sql-orm-client/src/collection.ts (1)
632-633: Consider centralizing mutation-default application across mutation paths.
applyMutationDefaultsis now orchestrated in both this file andmutation-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
⛔ Files ignored due to path filters (2)
packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.tsis excluded by!**/generated/**packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.jsonis excluded by!**/generated/**
📒 Files selected for processing (12)
packages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/3-extensions/sql-orm-client/src/collection.tspackages/3-extensions/sql-orm-client/src/mutation-executor.tspackages/3-extensions/sql-orm-client/test/collection-contract.test.tspackages/3-extensions/sql-orm-client/test/fixtures/contract.tspackages/3-extensions/sql-orm-client/test/integration/create.test.tspackages/3-extensions/sql-orm-client/test/integration/delete.test.tspackages/3-extensions/sql-orm-client/test/integration/helpers.tspackages/3-extensions/sql-orm-client/test/integration/runtime-helpers.tspackages/3-extensions/sql-orm-client/test/integration/update.test.tspackages/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
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 -->
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 -->
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 -->
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 -->
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 -->
Fixes https://linear.app/prisma-company/issue/TML-2171/orm-client-create-doesnt-apply-execution-mutation-defaults
The problem was in two places:
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
Tests
Chores