-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
Summary
The WHERE clause callback currently provides comparison operations (eq, ne, gt, exists, etc.) but no logical operators. Users who need AND/OR must manually compose template literal strings:
.where(({ from, to }, { lte, gte, notExists }) => {
return `${lte(from, epoch)} AND (${gte(to, epoch)} OR ${notExists(to)})`;
})This proposal adds and and or as first-class operations:
.where(({ from, to }, { lte, gte, notExists, and, or }) => {
return and(lte(from, epoch), or(gte(to, epoch), notExists(to)));
})Motivation
- Consistency — comparison operators are functions, but logical composition requires string interpolation
- Composability —
and/orcan be nested arbitrarily:or(and(...), and(...)) - Conditional expressions — accepts
undefinedvalues (filtered out), enabling Drizzle ORM-style patterns:
.where(({ animal, dangerous }, { eq, exists, or }) =>
or(
eq(animal, "Cow"),
shouldFilterDangerous ? exists(dangerous) : undefined,
)
)Behavior
and(...expressions)/or(...expressions)— joins withAND/OR, wrapped in parentheses- Single argument — returns unwrapped
- No arguments or all
undefined— returns empty string - Accepts
(string | undefined)[] - Fully backward compatible — existing template literal usage continues to work
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels