From b4b57781b4e128c220cb1274ded0cdea8de314b2 Mon Sep 17 00:00:00 2001 From: Jon Harrell <4829245+jharrell@users.noreply.github.com> Date: Wed, 3 Jul 2024 14:32:23 -0500 Subject: [PATCH 1/2] document behavior of not with null values. Resolves DA-623. Resolves #3812. --- .../050-prisma-client-reference.mdx | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/content/200-orm/500-reference/050-prisma-client-reference.mdx b/content/200-orm/500-reference/050-prisma-client-reference.mdx index f7ab37ad16..5cb1580b1a 100644 --- a/content/200-orm/500-reference/050-prisma-client-reference.mdx +++ b/content/200-orm/500-reference/050-prisma-client-reference.mdx @@ -3560,13 +3560,34 @@ const result = await prisma.user.findMany({ }) ``` +:::warning + +`not` will return all items that do not match a given value. However, if the column is nullable, `NULL` values will not be returned. If you require null values to be returned, use an [`OR`](#or) to include `NULL` values. + +::: + +##### Return all users where `name` does **not** equal `"Eleanor"` **including** users where `name` is `NULL` + +```ts +await prisma.user.findMany({ + where: { + OR: [ + { name: { not: 'Eleanor' } }, + { name: null } + ] + } +}) +``` + ### `in` Value `n` exists in list. -#### Remarks +:::note -- `null` values are not returned. For example, if you combine `in` and `NOT` to return user whose name is _not_ in the list, users with `null` value names are not returned. +`null` values are not returned. For example, if you combine `in` and `NOT` to return user whose name is _not_ in the list, users with `null` value names are not returned. + +::: #### Examples From 35c8a8ab88af915b268bb4821ca407dc76d4db03 Mon Sep 17 00:00:00 2001 From: Jon Harrell <4829245+jharrell@users.noreply.github.com> Date: Tue, 9 Jul 2024 09:09:07 -0500 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> --- content/200-orm/500-reference/050-prisma-client-reference.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/200-orm/500-reference/050-prisma-client-reference.mdx b/content/200-orm/500-reference/050-prisma-client-reference.mdx index 5cb1580b1a..a6cd11ea3c 100644 --- a/content/200-orm/500-reference/050-prisma-client-reference.mdx +++ b/content/200-orm/500-reference/050-prisma-client-reference.mdx @@ -3562,7 +3562,7 @@ const result = await prisma.user.findMany({ :::warning -`not` will return all items that do not match a given value. However, if the column is nullable, `NULL` values will not be returned. If you require null values to be returned, use an [`OR`](#or) to include `NULL` values. +`not` will return all items that do not match a given value. However, if the column is nullable, `NULL` values will not be returned. If you require null values to be returned, use an [`OR`](#or) operator to include `NULL` values. ::: @@ -3585,7 +3585,7 @@ Value `n` exists in list. :::note -`null` values are not returned. For example, if you combine `in` and `NOT` to return user whose name is _not_ in the list, users with `null` value names are not returned. +`null` values are not returned. For example, if you combine `in` and `NOT` to return a user whose name is _not_ in the list, users with `null` value names are not returned. :::