[PR #5997] feat(adapter): add support for IS (NOT) NULL operators #6372

Open
opened 2026-03-13 12:56:23 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5997
Author: @Zollerboy1
Created: 11/14/2025
Status: 🔄 Open

Base: canaryHead: feat/adapter-where-is-null


📝 Commits (7)

  • f772aad feat(adapter): add support for "is (not) null" operators
  • 7fe6ac6 test(adapter): add tests for "is (not) null" operators
  • 4adf0dc Merge branch 'canary' into feat/adapter-where-is-null
  • b26c08d Merge branch 'canary' into feat/adapter-where-is-null
  • 2226687 Merge branch 'canary' into feat/adapter-where-is-null
  • a959850 Don't remove deprecated type
  • 21409d1 Fix linter errors

📊 Changes

10 files changed (+272 additions, -118 deletions)

View changed files

📝 packages/better-auth/src/adapters/drizzle-adapter/drizzle-adapter.ts (+38 -110)
📝 packages/better-auth/src/adapters/kysely-adapter/kysely-adapter.ts (+8 -0)
📝 packages/better-auth/src/adapters/memory-adapter/memory-adapter.ts (+4 -0)
📝 packages/better-auth/src/adapters/mongodb-adapter/mongodb-adapter.ts (+12 -0)
📝 packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts (+6 -0)
📝 packages/better-auth/src/adapters/tests/basic.ts (+175 -0)
📝 packages/better-auth/src/types/adapter.ts (+2 -1)
📝 packages/core/src/db/adapter/factory.ts (+11 -2)
📝 packages/core/src/db/adapter/index.ts (+13 -2)
📝 packages/core/src/db/adapter/types.ts (+3 -3)

📄 Description

This PR makes it possible to filter fields by NULL using the adapter:

const users = await ctx.context.internalAdapter.listUsers(limit, offset, sortBy, [
  {
    field: 'image',
    operator: 'is_not_null'
  }
]);

In standard SQL, NULL = NULL is not true, so filtering fields by NULL cannot be done using the eq/ne operators.


Summary by cubic

Adds is_null and is_not_null operators to all adapters so you can filter NULL values correctly. This replaces trying to use eq/ne with NULL, which doesn’t work in SQL.

  • New Features

    • Support is_null and is_not_null in Drizzle, Prisma, Kysely, MongoDB, and Memory adapters.
    • Adapter factory handles these as unary operators (no value).
    • Added tests for both operators, including AND/OR combinations.
  • Migration

    • Use operator "is_null" or "is_not_null" instead of eq/ne when filtering NULLs.
    • Do not pass a value for these operators (they are unary).
    • If you type against Where with value always required, update to the new union or use CleanedWhere.

Written for commit 21409d11ad. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5997 **Author:** [@Zollerboy1](https://github.com/Zollerboy1) **Created:** 11/14/2025 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `feat/adapter-where-is-null` --- ### 📝 Commits (7) - [`f772aad`](https://github.com/better-auth/better-auth/commit/f772aada02ccc4f947143731e5612966c3c85bc3) feat(adapter): add support for "is (not) null" operators - [`7fe6ac6`](https://github.com/better-auth/better-auth/commit/7fe6ac648d8ee44b04864eeec44751fc52ec0497) test(adapter): add tests for "is (not) null" operators - [`4adf0dc`](https://github.com/better-auth/better-auth/commit/4adf0dc40e0b5bcc18d1f3e52bbcb9005e0cf36d) Merge branch 'canary' into feat/adapter-where-is-null - [`b26c08d`](https://github.com/better-auth/better-auth/commit/b26c08da63efd8661019710999dcc0e8ddaf4603) Merge branch 'canary' into feat/adapter-where-is-null - [`2226687`](https://github.com/better-auth/better-auth/commit/222668777cfef90e69a1c2bdba4335c32320ff4c) Merge branch 'canary' into feat/adapter-where-is-null - [`a959850`](https://github.com/better-auth/better-auth/commit/a9598500e4f0dd45e2369e5a534ed21f829dae36) Don't remove deprecated type - [`21409d1`](https://github.com/better-auth/better-auth/commit/21409d11adf73e42e33acddd4a3deae65e6c0bad) Fix linter errors ### 📊 Changes **10 files changed** (+272 additions, -118 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/drizzle-adapter/drizzle-adapter.ts` (+38 -110) 📝 `packages/better-auth/src/adapters/kysely-adapter/kysely-adapter.ts` (+8 -0) 📝 `packages/better-auth/src/adapters/memory-adapter/memory-adapter.ts` (+4 -0) 📝 `packages/better-auth/src/adapters/mongodb-adapter/mongodb-adapter.ts` (+12 -0) 📝 `packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts` (+6 -0) 📝 `packages/better-auth/src/adapters/tests/basic.ts` (+175 -0) 📝 `packages/better-auth/src/types/adapter.ts` (+2 -1) 📝 `packages/core/src/db/adapter/factory.ts` (+11 -2) 📝 `packages/core/src/db/adapter/index.ts` (+13 -2) 📝 `packages/core/src/db/adapter/types.ts` (+3 -3) </details> ### 📄 Description This PR makes it possible to filter fields by `NULL` using the adapter: ```ts const users = await ctx.context.internalAdapter.listUsers(limit, offset, sortBy, [ { field: 'image', operator: 'is_not_null' } ]); ``` In standard SQL, `NULL = NULL` is not true, so filtering fields by `NULL` cannot be done using the `eq`/`ne` operators. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds is_null and is_not_null operators to all adapters so you can filter NULL values correctly. This replaces trying to use eq/ne with NULL, which doesn’t work in SQL. - New Features - Support is_null and is_not_null in Drizzle, Prisma, Kysely, MongoDB, and Memory adapters. - Adapter factory handles these as unary operators (no value). - Added tests for both operators, including AND/OR combinations. - Migration - Use operator "is_null" or "is_not_null" instead of eq/ne when filtering NULLs. - Do not pass a value for these operators (they are unary). - If you type against Where with value always required, update to the new union or use CleanedWhere. <sup>Written for commit 21409d11adf73e42e33acddd4a3deae65e6c0bad. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:56:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#6372