From 1c5dfa2b8e5cd8d29ccc2e80cf6f2e2b3f87b780 Mon Sep 17 00:00:00 2001 From: Miguel Fernandez Date: Tue, 8 Nov 2022 18:43:52 +0100 Subject: [PATCH] Test missing property on FindXOrThrow returns null Closes https://github.com/prisma/prisma/pull/15887 Closes https://github.com/prisma/prisma/issues/10642 Co-authored-by: Sergey Tatarintsev --- .../tests/functional/fluent-api/tests.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/client/tests/functional/fluent-api/tests.ts b/packages/client/tests/functional/fluent-api/tests.ts index f2d350ee4f2a..d1e3a72ab5f7 100644 --- a/packages/client/tests/functional/fluent-api/tests.ts +++ b/packages/client/tests/functional/fluent-api/tests.ts @@ -149,6 +149,18 @@ testMatrix.setupTestSuite(() => { expect(posts).toEqual([expect.objectContaining({ title })]) }) + test('findFirstOrThrow where nested entity is not found', async () => { + const property = await prisma.user + .findFirstOrThrow({ + where: { + email, + }, + }) + .property() + + expect(property).toBeNull() + }) + test('findUniqueOrThrow', async () => { const posts = await prisma.user .findUniqueOrThrow({ @@ -161,6 +173,18 @@ testMatrix.setupTestSuite(() => { expect(posts).toEqual([expect.objectContaining({ title })]) }) + test('findUniqueOrThrow where nested entity is not found', async () => { + const property = await prisma.user + .findUniqueOrThrow({ + where: { + email, + }, + }) + .property() + + expect(property).toBeNull() + }) + test('create', async () => { const posts = await prisma.user .create({