Skip to content

fix: support joins that do not require strict equality#29251

Merged
jacek-prisma merged 5 commits intomainfrom
fix/strict-equality-joins
Feb 27, 2026
Merged

fix: support joins that do not require strict equality#29251
jacek-prisma merged 5 commits intomainfrom
fix/strict-equality-joins

Conversation

@jacek-prisma
Copy link
Copy Markdown
Contributor

@jacek-prisma jacek-prisma commented Feb 25, 2026

TML-1868

Adds support for a new canAssumeStrictEquality flag used for in-memory joins. When it's set to false, we infer the type of the key present on the parent rows and inject casts for children rows. Fixes some MySQL edge cases.

Fixes #29122

Engine PR: prisma/prisma-engines#5785

Summary by CodeRabbit

  • Bug Fixes

    • Improved join key matching with optional per-field value mapping/type casting and a new flag to control strict-equality assumptions.
    • Standardized validation error identifiers to camelCase for more consistent error reporting.
  • Tests

    • Added MySQL-only functional tests for view relations with large BigInt keys.
  • Chores

    • Updated internal engine/tooling version references.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 25, 2026

Walkthrough

Adds optional per-field mappers for record key generation and threads a new canAssumeStrictEquality flag through query planning and interpretation to enable inferred key casts. Renames validation error property to camelCase. Adds MySQL BIGINT view-relation functional tests and updates sample query plans and some dependency versions.

Changes

Cohort / File(s) Summary
Record key generation
packages/client-engine-runtime/src/interpreter/in-memory-processing.ts
getRecordKey signature extended to accept mappers?: ((value: unknown)=>unknown)[]; applies per-field mapper (preserving null) when present before JSON-stringifying the key.
Query interpreter & key-casting logic
packages/client-engine-runtime/src/interpreter/query-interpreter.ts
attachChildrenToParents gains canAssumeStrictEquality: boolean; adds inferKeyCasts(rows, keys) returning per-key cast functions; uses mappers when strict equality cannot be assumed; refactors parent/child key handling.
Query plan shape & errors
packages/client-engine-runtime/src/query-plan.ts
QueryPlanNode join args now include canAssumeStrictEquality: boolean. ValidationError variants renamed field error_identifiererrorIdentifier.
Validation helpers
packages/client-engine-runtime/src/interpreter/validation.ts
Switched to error.errorIdentifier in renderMessage and getErrorCode; logic unchanged otherwise.
Bench sample plans
packages/client-engine-runtime/bench/sample-query-plans.ts
Added canAssumeStrictEquality: true across multiple join nodes in sample/benchmark plans.
Functional tests (MySQL BIGINT view relation)
packages/client/tests/functional/issues/29122-mysql-bigint-view-relation/_matrix.ts, packages/client/tests/functional/issues/29122-mysql-bigint-view-relation/prisma/_schema.ts, packages/client/tests/functional/issues/29122-mysql-bigint-view-relation/tests.ts
Adds MySQL-only test matrix, Prisma schema with a view exposing BIGINT keys, and regression test validating view-relation behavior with bigint keys.
Dependency bumps
packages/*/package.json (multiple) packages/client-generator-js/package.json, packages/client-generator-ts/package.json, packages/client/package.json, packages/engines/package.json, packages/fetch-engine/package.json, packages/internals/package.json, packages/migrate/package.json, packages/schema-files-loader/package.json
Bumped various @prisma/* engine/schema dependency versions to 7.5.0-10... across several package.json files; no code behavior changes.

Suggested labels

lgtm

Suggested reviewers

  • aqrln
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: support joins that do not require strict equality' accurately describes the main change enabling non-strict equality joins for type mismatches.
Linked Issues check ✅ Passed The PR implements all key objectives: adds canAssumeStrictEquality flag for in-memory joins, infers key type casts when strict equality cannot be assumed, and enables correct relation matching despite database type mismatches to fix issue #29122.
Out of Scope Changes check ✅ Passed Besides the main scope, the PR includes error_identifier to errorIdentifier renaming in query-plan.ts and validation.ts, which is tangential to the join equality feature but supports the overall schema consistency improvements.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/strict-equality-joins

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c33e8f8 and 8abc803.

📒 Files selected for processing (6)
  • packages/client-engine-runtime/src/interpreter/in-memory-processing.ts
  • packages/client-engine-runtime/src/interpreter/query-interpreter.ts
  • packages/client-engine-runtime/src/query-plan.ts
  • packages/client/tests/functional/issues/29122-mysql-bigint-view-relation/_matrix.ts
  • packages/client/tests/functional/issues/29122-mysql-bigint-view-relation/prisma/_schema.ts
  • packages/client/tests/functional/issues/29122-mysql-bigint-view-relation/tests.ts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 25, 2026

size-limit report 📦

Path Size
packages/client/runtime/index-browser.js 2.23 KB (0%)
packages/client/runtime/index-browser.d.ts 3.28 KB (0%)
packages/cli/build/index.js 2.5 MB (+0.01% 🔺)
packages/client/prisma-client-0.0.0.tgz 26.81 MB (+0.02% 🔺)
packages/cli/prisma-0.0.0.tgz 12.84 MB (+0.02% 🔺)
packages/bundle-size/da-workers-libsql/output.tgz 1.33 MB (+0.01% 🔺)
packages/bundle-size/da-workers-neon/output.tgz 1.39 MB (+0.02% 🔺)
packages/bundle-size/da-workers-pg/output.tgz 1.38 MB (+0.02% 🔺)
packages/bundle-size/da-workers-planetscale/output.tgz 1.33 MB (+0.03% 🔺)
packages/bundle-size/da-workers-d1/output.tgz 1.3 MB (+0.01% 🔺)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 25, 2026

🟢 All good, this PR is no longer uses custom engine.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8abc803 and f1af039.

📒 Files selected for processing (3)
  • packages/client-engine-runtime/bench/sample-query-plans.ts
  • packages/client-engine-runtime/src/interpreter/in-memory-processing.ts
  • packages/client/tests/functional/issues/29122-mysql-bigint-view-relation/tests.ts

jacek-prisma added a commit to prisma/prisma-engines that referenced this pull request Feb 27, 2026
[TML-1868](https://linear.app/prisma-company/issue/TML-1868/fix-mysql-bigint-relation-issue)

/prisma-branch fix/strict-equality-joins

Client PR: prisma/prisma#29251

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

* **New Features**
* Joins now carry a flag to enable stricter equality assumptions when
supported, improving cross-database join handling.
* Validation expressions include richer context for clearer error
reporting.

* **Chores**
* Connector implementations updated to advertise support for
strict-equality joins where applicable, enabling optimized query
generation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86ea036 and 61e8d9c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • packages/client-engine-runtime/src/interpreter/query-interpreter.ts
  • packages/client-generator-js/package.json
  • packages/client-generator-ts/package.json
  • packages/client/package.json
  • packages/engines/package.json
  • packages/fetch-engine/package.json
  • packages/internals/package.json
  • packages/migrate/package.json
  • packages/schema-files-loader/package.json

@jacek-prisma jacek-prisma requested a review from aqrln February 27, 2026 11:46
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 27, 2026
@jacek-prisma jacek-prisma merged commit 90d119c into main Feb 27, 2026
494 of 499 checks passed
@jacek-prisma jacek-prisma deleted the fix/strict-equality-joins branch February 27, 2026 13:39
jacek-prisma added a commit that referenced this pull request Feb 27, 2026
[TML-1868](https://linear.app/prisma-company/issue/TML-1868/fix-mysql-bigint-relation-issue)

Adds support for a new `canAssumeStrictEquality` flag used for in-memory
joins. When it's set to false, we infer the type of the key present on
the parent rows and inject casts for children rows. Fixes some MySQL
edge cases.

Fixes #29122

Engine PR: prisma/prisma-engines#5785

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

* **Bug Fixes**
* Improved join key matching with optional per-field value mapping/type
casting and a new flag to control strict-equality assumptions.
* Standardized validation error identifiers to camelCase for more
consistent error reporting.

* **Tests**
* Added MySQL-only functional tests for view relations with large BigInt
keys.

* **Chores**
  * Updated internal engine/tooling version references.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Prismo <prismabots@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

View relations broken in Prisma v7 when MySQL view returns BIGINT from subquery

3 participants