Renders the compiled filter AST to raw parameterized SQL for Knex (no driver dependency).
applyFiltersToKnex applies it via whereRaw; buildWhereSql returns the { sql, bindings }.
Dialect-aware (dialect, default "postgres"): the array ops and ILIKE are spelled
per dialect: PG native @>/<@/&& + ILIKE, MySQL JSON_CONTAINS/JSON_OVERLAPS +
LIKE, SQLite json_each(…) subqueries + LIKE (see {@link SqlDialect}). On MySQL/SQLite,
LIKE gets an ESCAPE clause so the escaped %/_/\ in contains/startsWith/
endsWith match literally, and MySQL identifiers are quoted with backticks. There is no
knex import: any object with whereRaw(sql, bindings) works, so Knex stays your app’s
dependency. Column identifiers are server-owned and validated; values are bound (?).
Compile filters with buildWhereSql and add the result to a Knex query builder with query.whereRaw(sql, bindings). When no filter survives the allow-list, whereRaw is not called. Returns the same query for chaining. Works with any object that has a whereRaw(sql, bindings) method, so this module never imports knex.
Compile a recursive and/or/notFilterNode tree into a parameterized { sql, bindings } fragment (or null). Same allow-list and dialect rules as buildWhereSql.
Compile a flat, AND-combined list of column filters into a parameterized { sql, bindings } fragment for Knex’s whereRaw (or any driver that takes ? placeholders). Only fields in spec whose kind matches the filter’s kind are kept; the rest are silently dropped. Returns null when nothing survives. A date preset filter needs resolveDate (it throws without one). dialect (default "postgres") changes the array ops, ilike, the LIKE escape clause and identifier quoting (backticks on MySQL).
Render an already-compiled CompiledWhere AST (from compileFilters / compileFilterNode in @xtandard/lib/filters) to a parameterized { sql, bindings } fragment, looking each field up in columns (column strings, validated and quoted). Conditions on fields missing from columns are dropped; null (or an AST that drops to nothing) gives null. Most code calls buildWhereSql, which compiles and renders in one step.
Allow-list a public field as an array filter over a column named by a column string ("tags" or "posts.tags"). The SQL depends on dialect: a native array with @>/<@/&& on Postgres, a JSON column with JSON_CONTAINS/JSON_OVERLAPS on MySQL, and json_each(…) subqueries on SQLite.
Allow-list a public field as a date filter over a timestamp column, named by a column string ("created_at" or "posts.created_at", quoted per part; anything else throws). A date preset needs the resolveDate you pass to buildWhereSql, and becomes a half-open [start, end) window.
Allow-list a public field as an enum filter (eq/ne/inArray/notInArray/null checks) over a column named by a column string ("status" or "tasks.status").
Allow-list a public field as a number filter over a numeric column, named by a column string ("total" or "orders.total"). between renders as >= ? AND <= ?.
Allow-list a public field as a text filter over a string column, named by a column string ("name" or "users.name", quoted per part; anything else throws). contains/startsWith/ endsWith render as ILIKE on Postgres and LIKE on MySQL/SQLite, with the input’s %/_/\ escaped (plus an ESCAPE clause on MySQL/SQLite, so they match literally).