drizzle-team / drizzle-team/drizzle-orm
[BUG]: rqb-v2 - Filtering breaks with filters { field: null }
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
drizzle-orm-1.0.0-beta.15-859cf75
### What version of `drizzle-kit` are you using?
n/a
### Other packages
_No response_
### Describe the Bug
When I query (using rqb-v2) and I want to filter for a field being null, drizzle throws an error
```js
this.drizzle.query.table.findMany({
where: {
field: null
},
});
```
```log
[2026-03-01 13:07:28.203 -0300] ERROR: Cannot convert undefined or null to object {"reqId":"1abe221c-6d97-4790-9b60-191db0a5d2bc","context":"ExceptionsHandler"}
err: {
"type": "Error",
"message": "Cannot convert undefined or null to object",
"stack":
TypeError: Cannot convert undefined or null to object
at Function.entries ()
at relationsFieldFilterToSQL (/path/to/project/node_modules/src/relations.ts:1263:25)
at relationsFilterToSQL (/path/to/project/node_modules/src/relations.ts:1427:24)
at PgDialect.buildRelationalQuery (/path/to/project/node_modules/src/pg-core/dialect.ts:1050:14)
at PgAsyncRelationalQuery._getQuery (/path/to/project/node_modules/src/pg-core/query-builders/query.ts:115:23)
at PgAsyncRelationalQuery._toSQL (/path/to/project/node_modules/src/pg-core/query-builders/query.ts:130:22)
at (/path/to/project/node_modules/src/pg-core/async/query.ts:29:39)
at Object.startActiveSpan (/path/to/project/node_modules/src/tracing.ts:27:11)
at PgAsyncRelationalQuery._prepare (/path/to/project/node_modules/src/pg-core/async/query.ts:28:17)
at (/path/to/project/node_modules/src/pg-core/async/query.ts:60:16)
}
```
If the field is anything other than **null**, it works (falling back to the **"eq"** operator)
There is a workaround for that which is to use the **isNull** operator
```js
this.drizzle.query.table.findMany({
where: {
field: { isNull: true }
},
});
```
I'm wondering if this is expected or if **null** values should behave like other values fallback to the **"eq"** operator
Contributor guide
Research direction
Start with relations.ts at relationsFieldFilterToSQL, then follow its caller relationsFilterToSQL and the PgDialect relational-query path shown in the stack trace. Reproduce the rqb-v2 findMany query with { field: null }, compare it with the isNull workaround, and confirm that null filtering completes without the reported TypeError and has the agreed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100