Skip to content

Commit

Permalink
fix(client): minimal errors (#12586)
Browse files Browse the repository at this point in the history
  • Loading branch information
millsp committed Apr 1, 2022
1 parent f5e2e3a commit bfe5ce3
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 46 deletions.
Expand Up @@ -5,26 +5,6 @@ Argument age: Got invalid value 'thisisastringwith30characters' on prisma.update
`;

exports[`int-errors overflow-int 1`] = `
exports[`int-errors overflow-int 1`] = `Value out of range for the type. Out of range value for column 'age' at row 1`;

Invalid \`prisma.user.update()\` invocation in
/client/src/__tests__/integration/errors/int-errors/test.ts:0:0
54
55 test('overflow-int', async () => {
56 try {
→ 57 await prisma.user.update(
Value out of range for the type. Out of range value for column 'age' at row 1
`;
exports[`int-errors signed-int 1`] = `
Invalid \`prisma.user.update()\` invocation in
/client/src/__tests__/integration/errors/int-errors/test.ts:0:0
68
69 test('signed-int', async () => {
70 try {
→ 71 await prisma.user.update(
Value out of range for the type. Out of range value for column 'age' at row 1
`;
exports[`int-errors signed-int 1`] = `Value out of range for the type. Out of range value for column 'age' at row 1`;
Expand Up @@ -111,17 +111,9 @@ test('wrong-native-types-mysql C: Char, VarChar, TinyText, Text, MediumText, Lon
lText: true,
},
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
Invalid \`prisma.c.create()\` invocation in
/client/src/__tests__/integration/errors/wrong-native-types-mysql/test.ts:0:0
100 }
101
102 await expect(async () =>
→ 103 prisma.c.create(
The provided value for the column is too long for the column's type. Column: char
`)
).rejects.toThrowErrorMatchingInlineSnapshot(
`The provided value for the column is too long for the column's type. Column: char`,
)

await prisma.$disconnect()
})
Expand Down
Expand Up @@ -115,15 +115,7 @@ test('wrong-native-types-postgres C: Char, VarChar, Text, Bit, VarBit, Uuid', as
},
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
Invalid \`prisma.c.create()\` invocation in
/client/src/__tests__/integration/errors/wrong-native-types-postgres/test.ts:0:0
103 }
104
105 await expect(async () =>
→ 106 prisma.c.create(
Error occurred during query execution:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: ToSql(4), cause: Some(Error { kind: ConversionError("Unexpected character for bits input. Expected only 1 and 0."), original_code: None, original_message: None }) }) })
`)

Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/runtime/core/model/applyFluent.ts
Expand Up @@ -3,7 +3,7 @@ import type { DMMF } from '@prisma/generator-helper'
import type { Client } from '../../getPrismaClient'
import { deepSet } from '../../utils/deep-set'
import { getCallSite } from '../utils/getCallSite'
import type { ModelAction } from './applyModel'
import type { applyModel, ModelAction } from './applyModel'
import type { UserArgs } from './UserArgs'
import { defaultProxyHandlers } from './utils/defaultProxyHandlers'

Expand Down Expand Up @@ -96,7 +96,7 @@ export function applyFluent(

// we return a regular model action but proxy its return
return (userArgs?: UserArgs) => {
const callsite = getCallSite()
const callsite = getCallSite(client._errorFormat)
// ! first call: nextDataPath => [], nextUserArgs => userArgs
const nextDataPath = getNextDataPath(fluentPropName, prevDataPath)
const nextUserArgs = getNextUserArgs(userArgs, prevUserArgs, nextDataPath)
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/runtime/core/utils/getCallSite.ts
Expand Up @@ -3,7 +3,7 @@
* @param errorFormat
* @returns
*/
export function getCallSite(errorFormat?: string) {
export function getCallSite(errorFormat: string) {
if (errorFormat === 'minimal') {
return undefined
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/runtime/getPrismaClient.ts
Expand Up @@ -721,7 +721,7 @@ Or read our docs at https://www.prisma.io/docs/concepts/components/prisma-client
clientMethod: 'runCommandRaw',
dataPath: [],
action: 'runCommandRaw',
callsite: getCallSite(),
callsite: getCallSite(this._errorFormat),
runInTransaction: !!txId,
transactionId: txId,
otelCtx: otelCtx,
Expand Down

0 comments on commit bfe5ce3

Please sign in to comment.