Optionaldialect: DialectOptionaloptions: SqlCompilerOptionsSet the field mapping
Get the DB column name for an attribute
Get the attribute name for a DB column
Escape a value for use in SQL
Escape an identifier (column, table name)
Convert an attribute expression to SQL Handles fn(), col(), literal(), and plain strings
The attribute value (string, FnExpression, ColExpression, LiteralExpression, or array)
OptionaltableAlias: string
Optional table alias to prepend to column names
The SQL representation of the attribute
Process an attribute value (which could be a column name, fn expression, col expression, or literal) into a SQL expression string
The attribute value to process
OptionaltableAlias: string
Optional table alias to prefix column names with
The SQL expression string
Convert an attribute to SQL with optional alias Handles formats like:
The attribute (string or array with alias)
OptionaltableAlias: string
Optional table alias
SQL fragment with optional alias
Compile WHERE clause
Optionaloptions: { paramChar?: string }Compile LIMIT/OFFSET clause Handles SQLite which requires LIMIT when using OFFSET
Optionallimit: string | numberOptionaloffset: string | numberCompile GROUP BY clause Supports:
Optionalgroup: string | string[]OptionalgroupType: "rollup" | "cube" | "grouping" | "none"OptionalgroupingSets: string[][]Compile Common Table Expression (CTE) clause Supports both regular WITH and WITH RECURSIVE
Optionalctes: { name: string; columns?: string[]; query: string; recursive?: boolean }[]Compile HAVING clause for aggregation filtering Similar to WHERE but specifically for aggregated results Supports all operators: Op.gt, Op.eq, Op.between, etc. Also supports direct aggregation functions: COUNT(), SUM(), AVG(), MAX(), MIN()
Optionaloptions: { paramChar?: string }Compile a full SELECT query
Compile a PIVOT query - transform rows to columns
Compile a PIVOT query with specific pivot values (after they're resolved)
Compile an UNPIVOT query - transform columns to rows
Compile an INSERT query
Compile an UPDATE query
Compile a DELETE query
Compile a UNION/EXCEPT/INTERSECT query Supports combining multiple queries with UNION, UNION ALL, EXCEPT, or INTERSECT
The main query (uses same structure as compileSelect)
Array of union queries
Optionalorder?: OrderOrder by for the combined result
Optionallimit?: string | numberLimit for the combined result
Optionaloffset?: string | numberOffset for the combined result
Compile an EXCEPT query - returns rows from main query that don't exist in except query
Optionaloptions: { order?: Order; limit?: string | number; offset?: string | number }Compile an INTERSECT query - returns rows that exist in both queries
Optionaloptions: { order?: Order; limit?: string | number; offset?: string | number }Format SQL for different dialects
Compile PARTITION BY clause
Compile window frame specification Examples:
Compile lock options for row-level locking.
Delegates to the shared dialect lock compiler so this and each dialect's
own buildSelectQuery() can never disagree about what a given lock shape
means. Supports true, a level string, and the
{ level, nowait, skipLocked, of } object form; throws when the named
dialect cannot express the requested lock.
Lock options
The database dialect
The compiled lock SQL clause, or an empty string for no lock and for dialects with no trailing locking clause (SQLite, SQL Server, ...)
Compile OVER clause with partition, order, and window frame
Compile a window function expression
The window function name (ROW_NUMBER, RANK, etc.)
Arguments to the window function
Window function options
The compiled SQL expression
Pretty print SQL
SQL Compiler class Compiles query objects to SQL strings with proper escaping