Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Drizzle ORM · Function

isNull

isNull creates a Drizzle filter for rows where a column or SQL expression is SQL NULL. Use it inside a query's where clause to generate an IS NULL predicate.

How it works

isNull builds a filter that matches rows where the supplied column or SQL expression has the SQL NULL value. Pass the resulting condition to a query builder's where method to generate an IS NULL predicate.

Syntax

isNull(column)

Parameters

NameTypeDescription
columnColumn or SQL expressionColumn or SQL expression whose value should be tested for SQL NULL.

Returns

A SQL filter condition representing an IS NULL predicate.

Key points

  • Import isNull from the drizzle-orm package.
  • isNull describes a condition for values that are SQL NULL.
  • The documented import uses a named import from drizzle-orm.
  • Use the returned predicate as the argument to where on a select query.
  • The generated SQL uses the IS NULL operator for the selected column.

Common mistakes

  • The predicate tests SQL NULL, not the JavaScript value undefined.

Example: Find rows with a null column

import { drizzle } from "drizzle-orm/node-postgres";
import { isNull } from "drizzle-orm";
import { users } from "./schema";

const db = drizzle(process.env.DATABASE_URL!);
const rows = await db.select().from(users).where(isNull(users.deletedAt));
console.log(rows);

Selects users whose deletedAt column contains SQL NULL.

When to use it

Find missing values

Retrieve records with an unset optional field.

Implement soft-delete filtering

Select records not yet marked as deleted.

Find unassociated records

Restrict a query to rows lacking a nullable relationship key.

Interview questions

QWhat does isNull do?

isNull is imported from drizzle-orm and accepts a column or SQL expression. Used in where, it produces an IS NULL condition for matching rows.

Follow-up: How would you match non-null values? Use the corresponding isNotNull operator in the same filter-operator family.

QHow do you use isNull in a query?

Call isNull with the target column, then pass the returned condition to where, such as where(isNull(table.column)). The documented SQL shape is a SELECT with table.column IS NULL.

Follow-up: How can this condition be combined with another predicate? Compose it with Drizzle's logical filter operators, such as and or or.

QWhy use a dedicated null predicate?

The function represents a SQL NULL comparison rather than an ordinary equality comparison. Its documented purpose is to filter rows whose value is null.

Follow-up: Why not use eq(column, null)? Use the dedicated null predicate so the generated SQL uses IS NULL semantics.

  • isNotNull
  • and
  • or
  • eq

Source: Filters - Drizzle ORM. Checked 2026-10-16.