Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineMatrix } from '../../_utils/defineMatrix'
import { Providers } from '../../_utils/providers'

export default defineMatrix(() => [
[{ provider: Providers.POSTGRESQL }, { provider: Providers.COCKROACHDB }, { provider: Providers.MYSQL }],
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import testMatrix from '../_matrix'

export default testMatrix.setupSchema(({ provider }) => {
return /* Prisma */ `
generator client {
provider = "prisma-client-js"
previewFeatures = ["relationJoins"]
}

datasource db {
provider = "${provider}"
}

model User {
id BigInt @id
name String
posts Post[]
}

model Post {
id BigInt @id
title String
authorId BigInt
author User @relation(fields: [authorId], references: [id])
}
`
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import testMatrix from './_matrix'
// @ts-ignore
import type { PrismaClient } from './generated/prisma/client'

declare let prisma: PrismaClient

// BigInt IDs that exceed Number.MAX_SAFE_INTEGER (2^53 - 1 = 9007199254740991)
const USER_ID = BigInt('312590077454712834')
const POST_ID = BigInt('412590077454712834')

testMatrix.setupTestSuite(
() => {
beforeAll(async () => {
await prisma.post.deleteMany()
await prisma.user.deleteMany()

await prisma.user.create({
data: {
id: USER_ID,
name: 'Alice',
posts: {
create: {
id: POST_ID,
title: 'Hello World',
},
},
},
})
})

test('preserves BigInt precision in relationJoins queries', async () => {
const user = await prisma.user.findUnique({
where: { id: USER_ID },
relationLoadStrategy: 'join',
include: { posts: true },
})

expect(user).not.toBeNull()
expect(user!.id).toBe(USER_ID)
expect(user!.posts).toHaveLength(1)
expect(user!.posts[0].id).toBe(POST_ID)
expect(user!.posts[0].authorId).toBe(USER_ID)
})

test('preserves BigInt precision in nested relationJoins queries', async () => {
const post = await prisma.post.findUnique({
where: { id: POST_ID },
relationLoadStrategy: 'join',
include: {
author: {
include: { posts: true },
},
},
})

expect(post).not.toBeNull()
expect(post!.id).toBe(POST_ID)
expect(post!.authorId).toBe(USER_ID)
expect(post!.author.id).toBe(USER_ID)
expect(post!.author.posts).toHaveLength(1)
expect(post!.author.posts[0].id).toBe(POST_ID)
})
},
{
optOut: {
from: ['mongodb', 'sqlite', 'sqlserver'],
reason: 'relationJoins not supported',
},
},
)
2 changes: 0 additions & 2 deletions packages/internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@
"@types/jest": "29.5.14",
"@types/node": "~20.19.24",
"@types/resolve": "1.20.6",
"archiver": "6.0.2",
"checkpoint-client": "1.1.33",
"cli-truncate": "4.0.0",
"empathic": "2.0.0",
"escape-string-regexp": "5.0.0",
"execa": "8.0.1",
"fast-glob": "3.3.3",
"find-up": "7.0.0",
"fp-ts": "2.16.9",
"fs-extra": "11.3.0",
Expand Down
Loading
Loading