Skip to content

Commit

Permalink
fix(client): use correct $-names in error messages (#13190)
Browse files Browse the repository at this point in the history
In error messages, `$queryRaw` and `$executeRaw` methods used to be
reported without leading $

Fixes #9388
  • Loading branch information
SevInf committed May 6, 2022
1 parent bd5784a commit 7cfb0e1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
Expand Up @@ -192,15 +192,15 @@ describe('interactive transactions', () => {

await expect(result).rejects.toThrowErrorMatchingInlineSnapshot(`
Invalid \`prisma.user.create()\` invocation in
/client/src/__tests__/integration/happy/interactive-transactions-postgres/test.ts:0:0
Invalid \`prisma.user.create()\` invocation in
/client/src/__tests__/integration/happy/interactive-transactions-postgres/test.ts:0:0
183 },
184 })
185
→ 186 await prisma.user.create(
Unique constraint failed on the fields: (\`email\`)
`)
183 },
184 })
185
→ 186 await prisma.user.create(
Unique constraint failed on the fields: (\`email\`)
`)

const users = await prisma.user.findMany()

Expand All @@ -226,15 +226,15 @@ describe('interactive transactions', () => {

await expect(result).rejects.toThrowErrorMatchingInlineSnapshot(`
Invalid \`transactionBoundPrisma.user.create()\` invocation in
/client/src/__tests__/integration/happy/interactive-transactions-postgres/test.ts:0:0
Invalid \`transactionBoundPrisma.user.create()\` invocation in
/client/src/__tests__/integration/happy/interactive-transactions-postgres/test.ts:0:0
217 })
218
219 const result = prisma.$transaction(async () => {
→ 220 await transactionBoundPrisma.user.create(
Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Committed'.
`)
217 })
218
219 const result = prisma.$transaction(async () => {
→ 220 await transactionBoundPrisma.user.create(
Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Committed'.
`)

const users = await prisma.user.findMany()

Expand Down Expand Up @@ -283,15 +283,15 @@ describe('interactive transactions', () => {

await expect(result).rejects.toThrowErrorMatchingInlineSnapshot(`
Invalid \`prisma.user.create()\` invocation in
/client/src/__tests__/integration/happy/interactive-transactions-postgres/test.ts:0:0
Invalid \`prisma.user.create()\` invocation in
/client/src/__tests__/integration/happy/interactive-transactions-postgres/test.ts:0:0
269 */
270 testIf(getClientEngineType() === ClientEngineType.Library)('batching rollback', async () => {
271 const result = prisma.$transaction([
→ 272 prisma.user.create(
Unique constraint failed on the fields: (\`email\`)
`)
269 */
270 testIf(getClientEngineType() === ClientEngineType.Library)('batching rollback', async () => {
271 const result = prisma.$transaction([
→ 272 prisma.user.create(
Unique constraint failed on the fields: (\`email\`)
`)

const users = await prisma.user.findMany()

Expand Down Expand Up @@ -319,11 +319,11 @@ describe('interactive transactions', () => {

await expect(result).rejects.toThrowErrorMatchingInlineSnapshot(`
Invalid \`prisma.executeRaw()\` invocation:
Invalid \`prisma.$executeRaw()\` invocation:
Raw query failed. Code: \`23505\`. Message: \`Key (id)=(1) already exists.\`
`)
Raw query failed. Code: \`23505\`. Message: \`Key (id)=(1) already exists.\`
`)

const users = await prisma.user.findMany()

Expand Down Expand Up @@ -384,15 +384,15 @@ describe('interactive transactions', () => {

await expect(result).rejects.toThrowErrorMatchingInlineSnapshot(`
Invalid \`prisma.user.create()\` invocation in
/client/src/__tests__/integration/happy/interactive-transactions-postgres/test.ts:0:0
Invalid \`prisma.user.create()\` invocation in
/client/src/__tests__/integration/happy/interactive-transactions-postgres/test.ts:0:0
370 })
371
372 const result = prisma.$transaction([
→ 373 prisma.user.create(
Unique constraint failed on the fields: (\`email\`)
`)
370 })
371
372 const result = prisma.$transaction([
→ 373 prisma.user.create(
Unique constraint failed on the fields: (\`email\`)
`)

const users = await prisma.user.findMany()

Expand Down
Expand Up @@ -317,11 +317,11 @@ describe('interactive transactions', () => {

await expect(result).rejects.toThrowErrorMatchingInlineSnapshot(`
Invalid \`prisma.executeRaw()\` invocation:
Invalid \`prisma.$executeRaw()\` invocation:
Raw query failed. Code: \`2067\`. Message: \`UNIQUE constraint failed: User.email\`
`)
Raw query failed. Code: \`2067\`. Message: \`UNIQUE constraint failed: User.email\`
`)

const users = await prisma.user.findMany()

Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/runtime/getPrismaClient.ts
Expand Up @@ -646,7 +646,7 @@ export function getPrismaClient(config: GetPrismaClientConfig) {
debug(`Prisma Client call:`)
return this._request({
args,
clientMethod: 'executeRaw',
clientMethod: '$executeRaw',
dataPath: [],
action: 'executeRaw',
callsite: getCallSite(this._errorFormat),
Expand Down Expand Up @@ -711,7 +711,7 @@ Or read our docs at https://www.prisma.io/docs/concepts/components/prisma-client
return createPrismaPromise((txId, lock, otelCtx) => {
return this._request({
args: { command: command },
clientMethod: 'runCommandRaw',
clientMethod: '$runCommandRaw',
dataPath: [],
action: 'runCommandRaw',
callsite: getCallSite(this._errorFormat),
Expand Down Expand Up @@ -822,7 +822,7 @@ Or read our docs at https://www.prisma.io/docs/concepts/components/prisma-client

return this._request({
args,
clientMethod: 'queryRaw',
clientMethod: '$queryRaw',
dataPath: [],
action: 'queryRaw',
callsite: getCallSite(this._errorFormat),
Expand Down

0 comments on commit 7cfb0e1

Please sign in to comment.