From f041d9669d97dc59b8ddea143e6c9653fbcbacb0 Mon Sep 17 00:00:00 2001 From: pierre Date: Thu, 10 Nov 2022 10:03:29 -1000 Subject: [PATCH] test(client): regression test for #16195 (#16214) --- .../16195-index-out-of-bounds/_matrix.ts | 24 +++++++++++++++++++ .../prisma/_schema.ts | 19 +++++++++++++++ .../issues/16195-index-out-of-bounds/tests.ts | 15 ++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 packages/client/tests/functional/issues/16195-index-out-of-bounds/_matrix.ts create mode 100644 packages/client/tests/functional/issues/16195-index-out-of-bounds/prisma/_schema.ts create mode 100644 packages/client/tests/functional/issues/16195-index-out-of-bounds/tests.ts diff --git a/packages/client/tests/functional/issues/16195-index-out-of-bounds/_matrix.ts b/packages/client/tests/functional/issues/16195-index-out-of-bounds/_matrix.ts new file mode 100644 index 000000000000..7a6b8ff0075c --- /dev/null +++ b/packages/client/tests/functional/issues/16195-index-out-of-bounds/_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/16195-index-out-of-bounds/prisma/_schema.ts b/packages/client/tests/functional/issues/16195-index-out-of-bounds/prisma/_schema.ts new file mode 100644 index 000000000000..c4ce3ca814a9 --- /dev/null +++ b/packages/client/tests/functional/issues/16195-index-out-of-bounds/prisma/_schema.ts @@ -0,0 +1,19 @@ +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)} + } + ` +}) diff --git a/packages/client/tests/functional/issues/16195-index-out-of-bounds/tests.ts b/packages/client/tests/functional/issues/16195-index-out-of-bounds/tests.ts new file mode 100644 index 000000000000..9aef4ac6ac45 --- /dev/null +++ b/packages/client/tests/functional/issues/16195-index-out-of-bounds/tests.ts @@ -0,0 +1,15 @@ +import { randomBytes } from 'crypto' + +import testMatrix from './_matrix' +// @ts-ignore +import type { PrismaClient } from './node_modules/@prisma/client' + +declare let prisma: PrismaClient + +const id = randomBytes(12).toString('hex') + +testMatrix.setupTestSuite((suiteConfig, suiteMeta) => { + test('transaction', async () => { + await prisma.$transaction([prisma.user.findUnique({ where: { id } }), prisma.user.findMany()]) + }) +})