-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
packages/client/tests/functional/issues/15204-conversion-error/_matrix.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
], | ||
]) |
20 changes: 20 additions & 0 deletions
20
packages/client/tests/functional/issues/15204-conversion-error/prisma/_schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
} | ||
` | ||
}) |
29 changes: 29 additions & 0 deletions
29
packages/client/tests/functional/issues/15204-conversion-error/tests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}, | ||
) |