From 6cbed47124c91315e7f56470b2c45c4044c28321 Mon Sep 17 00:00:00 2001 From: Sergey Tatarintsev Date: Mon, 17 Oct 2022 18:31:23 +0200 Subject: [PATCH] chore: Reproduction for #14373 --- .../issues/14373-batch-tx-error/_matrix.ts | 24 +++++++++++++++++++ .../14373-batch-tx-error/prisma/_schema.ts | 22 +++++++++++++++++ .../issues/14373-batch-tx-error/tests.ts | 24 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 packages/client/tests/functional/issues/14373-batch-tx-error/_matrix.ts create mode 100644 packages/client/tests/functional/issues/14373-batch-tx-error/prisma/_schema.ts create mode 100644 packages/client/tests/functional/issues/14373-batch-tx-error/tests.ts diff --git a/packages/client/tests/functional/issues/14373-batch-tx-error/_matrix.ts b/packages/client/tests/functional/issues/14373-batch-tx-error/_matrix.ts new file mode 100644 index 000000000000..7a6b8ff0075c --- /dev/null +++ b/packages/client/tests/functional/issues/14373-batch-tx-error/_matrix.ts @@ -0,0 +1,24 @@ +import { defineMatrix } from '../../_utils/defineMatrix' + +export default defineMatrix(() => [ + [ + { + provider: 'sqlite', + }, + { + provider: 'postgresql', + }, + { + provider: 'mysql', + }, + { + provider: 'mongodb', + }, + { + provider: 'cockroachdb', + }, + { + provider: 'sqlserver', + }, + ], +]) diff --git a/packages/client/tests/functional/issues/14373-batch-tx-error/prisma/_schema.ts b/packages/client/tests/functional/issues/14373-batch-tx-error/prisma/_schema.ts new file mode 100644 index 000000000000..a75c03293f54 --- /dev/null +++ b/packages/client/tests/functional/issues/14373-batch-tx-error/prisma/_schema.ts @@ -0,0 +1,22 @@ +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 User { + id ${idForProvider(provider)} + email String @unique + memo String? + createdAt DateTime @default(now()) + } + ` +}) diff --git a/packages/client/tests/functional/issues/14373-batch-tx-error/tests.ts b/packages/client/tests/functional/issues/14373-batch-tx-error/tests.ts new file mode 100644 index 000000000000..8a51ea1ac8c7 --- /dev/null +++ b/packages/client/tests/functional/issues/14373-batch-tx-error/tests.ts @@ -0,0 +1,24 @@ +// @ts-ignore +import type { PrismaClient } from '@prisma/client' + +import testMatrix from './_matrix' + +declare let prisma: PrismaClient + +testMatrix.setupTestSuite((suiteConfig, suiteMeta) => { + test('correctly reports error location for batch tx', async () => { + const result = prisma.$transaction([ + prisma.user.findMany({}), + prisma.user.update({ + where: { + id: 'not here', + }, + data: { + memo: 'id is 1', + }, + }), + ]) + + await expect(result).rejects.toThrowError('Invalid `prisma.user.update()` invocation') + }) +})