Comparison Operators
Compares a field against a value: equality, inequality, and ordering.
| Operator | SQL | Meaning |
|---|---|---|
eq | = / IS NULL | Equal to |
ne | != / IS NOT NULL | Not equal to |
neq | != / IS NOT NULL | Alias for ne |
gt | > | Greater than |
gte | >= | Greater than or equal |
lt | < | Less than |
lte | <= | Less than or equal |
eq
typescript
{ where: { status: { eq: 'active' } } }
// SQL: WHERE "status" = 'active'Notice: the bare shorthand { status: 'active' } (no operator key) means the same thing.
Edge cases:
{ eq: null }compiles toIS NULL, never= NULL.- Bare array
{ field: [1, 2, 3] }(no operator key) compiles toIN (1, 2, 3). - An explicit
{ eq: [1, 2, 3] }does not becomeIN- it compares the column to an array value. - Bare empty array
{ field: [] }matches no rows (WHERE false).
ne / neq
typescript
{ where: { status: { ne: 'deleted' } } }
// SQL: WHERE "status" != 'deleted'Notice: ne and neq are the same operator under two names.
Edge cases:
{ ne: null }compiles toIS NOT NULL.- SQL three-valued logic applies: a
NULLfield never matches{ ne: value }, becauseNULL <> valueis UNKNOWN. - Add an
orbranch to include NULL rows:{ or: [{ field: { ne: value } }, { field: null }] }.
gt
typescript
{ where: { price: { gt: 100 } } }
// SQL: WHERE "price" > 100Notice: works on numbers, dates, and strings (lexicographic comparison).
Edge cases:
{ gt: null }compiles to"price" > NULL, which is never true - no rows match.- Use
is/existsinstead to check for null. - Combine with other operators in the same object:
{ gte: 18, lt: 65 }.
gte
typescript
{ where: { quantity: { gte: 10 } } }
// SQL: WHERE "quantity" >= 10Notice: inclusive of the boundary value.
Edge cases:
- Same null behavior as
gt:{ gte: null }matches no rows.
lt
typescript
{ where: { stock: { lt: 5 } } }
// SQL: WHERE "stock" < 5Notice: exclusive of the boundary value.
Edge cases:
- Same null behavior as
gt:{ lt: null }matches no rows.
lte
typescript
{ where: { rating: { lte: 3 } } }
// SQL: WHERE "rating" <= 3Notice: inclusive of the boundary value.
Edge cases:
- Same null behavior as
gt:{ lte: null }matches no rows.
See also
- Filter System Overview - the
filtershape and the fullwhereoperator table - Range Operators -
between/notBetween, and thegte/lteequivalent shown above - Quick Reference - every operator, one line each
Files:
packages/connectors/src/relational/postgres/repositories/dialect/query.ts-PostgresQueryOperators.FNS, per-operator SQL builderspackages/connectors/src/relational/core/repositories/dialect/filter.ts-FilterBuilder, translatesTFilterto Drizzle/SQLpackages/filter/src/common/operators.ts-QueryOperatorsconstants