Renders the compiled filter AST to a Drizzle WHERE expression, plus keyset helpers (peer drizzle-orm).
The SQL dialect comes from the spec’s columns: on a SQLite or MySQL column, text matches
render as like … escape (those databases have no ilike, and the ESCAPE clause makes
the escaped %/_/\ match literally); Postgres keeps drizzle’s ilike. The array ops
are Postgres-only.
Allow-list a public field as an array filter over a Postgres array column (any element type). arrayContains/arrayContained/arrayOverlaps render as @>/<@/&&.
Compile a recursive and/or/notFilterNode tree into a Drizzle SQL. Same allow-list rules as buildWhere: leaves on unknown fields or with a mismatched kind are dropped, and where is undefined when nothing is left.
Compile a Sort into Drizzle orderBy SQL, allow-listed to columns (a per-resource map of sortable public field name → column). Unknown fields are dropped; an empty/all-dropped result falls back to defaultSort. Pair with a db.select(...).orderBy(...buildOrderBy(...).orderBy) — NOT the RQB query (RQB aliases the root table and breaks column-referencing SQL).
Compile a flat, AND-combined list of column filters into a Drizzle SQL for db.select().from(t).where(where). Only fields in spec whose kind matches the filter’s kind are kept (the allow-list); the rest are silently dropped. where is undefined when nothing survives, which Drizzle’s .where() treats as “no filter”. A date preset filter needs resolveDate (it throws without one).
AND together the defined conditions, skipping undefined ones: typically the filter WHERE from buildWhere and the keyset seek from createDrizzleKeyset().where(...), which is undefined on the first page. Returns undefined when every input is undefined.
Build a keyset (cursor) helper from a sort spec + the Drizzle columns each logical key maps to. The last sort column MUST be unique (a tiebreaker like id) so the cursor is stable.
Allow-list a public field as a date filter over a Drizzle column whose data type is Date (e.g. timestamp(…, { mode: "date" })). A date preset (is/before/after/between a period) needs the resolveDate you pass to buildWhere; it becomes a half-open [start, end) window. Passing a non-Date column is a compile error.
Allow-list a public field as an enum filter (eq/ne/inArray/notInArray/null checks) over a Drizzle string column, typically text(…, { enum: [...] }) or a pgEnum column.
Allow-list a public field as a number filter over a Drizzle numeric column (integer, real, …). between renders as >= from and <= to; notBetween as < from or > to. Passing a non-number column is a compile error.
Allow-list a public field as a text filter over a Drizzle string column (text, varchar, …). contains/startsWith/endsWith render as ilike with the input’s %/_/\ escaped; on a SQLite or MySQL column, as like … escape instead. Passing a non-string column is a compile error.
Render an already-compiled CompiledWhere AST (from compileFilters / compileFilterNode in @xtandard/lib/filters) to a Drizzle SQL, looking each field up in columns. Conditions on fields missing from columns are dropped; null (or an AST that drops to nothing) gives undefined. Most code calls buildWhere, which compiles and renders in one step.
The per-resource filter ALLOW-LIST. Clients send public field names; the spec maps each allowed field to its Drizzle column + data kind. Anything not in the spec is dropped (never trust client-supplied column access).
One allow-listed field: its filter kind plus the Drizzle column it reads. Build it with textField/numberField/dateField/enumField/booleanField/arrayField.