Skip to content

[pull] main from prisma:main#209

Merged
pull[bot] merged 2 commits intocode:mainfrom
prisma:main
Feb 25, 2026
Merged

[pull] main from prisma:main#209
pull[bot] merged 2 commits intocode:mainfrom
prisma:main

Conversation

@pull
Copy link

@pull pull bot commented Feb 25, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

gameroman and others added 2 commits February 25, 2026 10:38
Removes unused dependencies

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

## Summary by CodeRabbit

* **Chores**
* Removed unused development dependencies to streamline the build
process.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
)

## Summary

This PR adds a regression test for a critical bug where BigInt values
lose precision when using driver adapters (like `@prisma/adapter-pg`)
with the `relationJoins` preview feature enabled.

Fixes #29010

### The Problem

When `previewFeatures = ["relationJoins"]` is enabled, Prisma uses
lateral joins to fetch related data. The related records are returned as
JSON-aggregated columns. When parsing this JSON data, standard
`JSON.parse()` converts large integers (exceeding
`Number.MAX_SAFE_INTEGER`) to JavaScript Numbers, silently corrupting
the values.

**Example corruption:**
- Original value: `312590077454712834`
- After JSON.parse: `312590077454712800` (precision lost!)

### The Fix

The fix is implemented at the SQL level in `prisma-engines`:
- Postgres: cast BigInt to text in `JSONB_BUILD_OBJECT`
(prisma/prisma-engines#5745)
- MySQL + CockroachDB: cast BigInt/INT8 values to string in JSON
builders (prisma/prisma-engines#5752)

BigInt columns are cast to string before JSON aggregation, so values
arrive as strings and are correctly parsed without precision loss.

**Changes in this PR:**
- Added regression test in
`packages/client/tests/functional/issues/29010-bigint-precision-relation-joins/`
- Minor type safety improvement (explicit `as Value` cast) in
`data-mapper.ts`

## Reproduction

<details>
<summary>Schema</summary>

```prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters", "relationJoins"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id    BigInt     @id @default(autoincrement())
  files UserFile[]
}

model UserFile {
  id     String @id @default(uuid())
  userId BigInt
  user   User   @relation(fields: [userId], references: [id])
}
```

</details>

<details>
<summary>Test Code</summary>

```typescript
// Create test data
const user = await prisma.user.create({ data: {} })
const file = await prisma.userFile.create({ data: { userId: user.id } })

// Fetch with include (triggers relationJoins)
const result = await prisma.userFile.findUnique({
  where: { id: file.id },
  include: { user: true }
})

// Before fix: result.userId !== result.user.id (BigInt corrupted in nested relation)
// After fix: result.userId === result.user.id (correct)
```

</details>

## Test Plan

- [x] Regression test added for BigInt precision in relationJoins
queries
- [x] Test covers PostgreSQL, CockroachDB, and MySQL (requires updated
Wasm artifacts from prisma-engines#5752)
- [x] Tests nested relationJoins queries

## Breaking Changes

None. This is a bugfix that preserves intended behavior.

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

## Summary by CodeRabbit

## Release Notes

* **Bug Fixes**
* Improved JSON data parsing and type handling in data mapping
operations.

* **Tests**
* Added comprehensive test coverage for BigInt precision with
relationJoins across PostgreSQL, CockroachDB, and MySQL database
providers.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Oleksii Orlenko <alex@aqrln.net>
@pull pull bot locked and limited conversation to collaborators Feb 25, 2026
@pull pull bot added the ⤵️ pull label Feb 25, 2026
@pull pull bot merged commit 28d0981 into code:main Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants