Skip to content

Commit

Permalink
test(client): add regression test for #15204 (#15530)
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln committed Sep 27, 2022
1 parent fc7aa78 commit 3a8282b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineMatrix } from '../../_utils/defineMatrix'

export default defineMatrix(() => [
[
{
provider: 'sqlite',
},
],
[
{
fieldType: 'Int',
},
{
fieldType: 'BigInt',
},
],
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { idForProvider } from '../../../_utils/idForProvider'
import testMatrix from '../_matrix'

export default testMatrix.setupSchema(({ provider, fieldType }) => {
return /* Prisma */ `
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "${provider}"
url = env("DATABASE_URI_${provider}")
}
model TestModel {
id ${idForProvider(provider)}
field ${fieldType}
}
`
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import testMatrix from './_matrix'
// @ts-ignore
import type { PrismaClient } from './node_modules/@prisma/client'

declare let prisma: PrismaClient

// Regression test for https://github.com/prisma/prisma/issues/15204
testMatrix.setupTestSuite(
() => {
test('should return a descriptive error', async () => {
await prisma.$executeRaw`INSERT INTO "TestModel" ("id", "field") VALUES ("1", 1.84467440724388e+19)`

await expect(prisma.testModel.findMany()).rejects.toThrowError(
expect.objectContaining({
code: 'P2020',
message: expect.stringContaining(
'Value out of range for the type. Unable to convert BigDecimal value "18446744072438800000" to type i64',
),
}),
)
})
},
{
optOut: {
from: ['mysql', 'mongodb', 'sqlserver', 'postgresql', 'cockroachdb'],
reason: 'SQLite-specific test',
},
},
)

0 comments on commit 3a8282b

Please sign in to comment.