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
* test(client): int overflow * make tests pass for data proxy * add comment about the dataproxy issue * refactor: move to use allProviders Co-authored-by: Daniel Starns <danielstarns@hotmail.com>
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/client/tests/functional/issues/13913-integer-overflow/_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,4 @@ | ||
import { defineMatrix } from '../../_utils/defineMatrix' | ||
import { allProviders } from '../../_utils/providers' | ||
|
||
export default defineMatrix(() => [allProviders]) |
20 changes: 20 additions & 0 deletions
20
packages/client/tests/functional/issues/13913-integer-overflow/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 }) => { | ||
return /* Prisma */ ` | ||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
datasource db { | ||
provider = "${provider}" | ||
url = env("DATABASE_URI_${provider}") | ||
} | ||
model Resource { | ||
id ${idForProvider(provider)} | ||
number Int | ||
} | ||
` | ||
}) |
35 changes: 35 additions & 0 deletions
35
packages/client/tests/functional/issues/13913-integer-overflow/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,35 @@ | ||
import testMatrix from './_matrix' | ||
// @ts-ignore | ||
import type { PrismaClient } from './node_modules/@prisma/client' | ||
|
||
declare let prisma: PrismaClient | ||
|
||
testMatrix.setupTestSuite(() => { | ||
test('int overflow', async () => { | ||
const promise = prisma.resource.create({ | ||
data: { | ||
number: 2265000000, | ||
}, | ||
}) | ||
|
||
await expect(promise).rejects.toMatchObject({ | ||
message: expect.stringContaining('Failed to validate the query'), | ||
code: 'P2009', | ||
}) | ||
|
||
// TODO: stack trace is not able to locate this error via dataproxy | ||
if (!process.env.DATA_PROXY) { | ||
await expect(promise).rejects.toMatchPrismaErrorInlineSnapshot(` | ||
Invalid \`prisma.resource.create()\` invocation in | ||
/client/tests/functional/issues/13913-integer-overflow/tests.ts:0:0 | ||
XX | ||
XX testMatrix.setupTestSuite(() => { | ||
XX test('int overflow', async () => { | ||
→ XX const promise = prisma.resource.create( | ||
Failed to validate the query: \`Unable to match input value to any allowed input type for the field. Parse errors: [Query parsing/validation error at \`Mutation.createOneResource.data.ResourceCreateInput.number\`: Unable to fit integer value '2265000000' into a 32-bit signed integer for field 'number'., Query parsing/validation error at \`Mutation.createOneResource.data.ResourceUncheckedCreateInput.number\`: Unable to fit integer value '2265000000' into a 32-bit signed integer for field 'number'.]\` at \`Mutation.createOneResource.data\` | ||
`) | ||
} | ||
}) | ||
}) |