/** * One CRUD SQL builder for every engine, instead of one per adapter. * * Feature 3's last open item, the 4.3x LOC finding: `insert`/`update`/`delete` * built their SQL independently in all seven adapters. Building * `INSERT INTO x (a, b) VALUES (?, ?)` is not engine-specific work - Ruby has * always done it once - and the seven copies differed in exactly two ways: * * IDENTIFIER QUOTING "col" | `col` | [col] | Firebird's fbQuote * PARAMETER MARKER ? | $1 | @p1 * * Both are captured in a `Dialect` below, so the builders are shared and each * adapter declares only what genuinely differs about its engine. * * These functions build STRINGS and nothing else. Execution and result * extraction stay in the adapters on purpose: those really are per-driver * (`client.query` vs `lastInsertRowid` vs a Firebird transaction handle), and * folding them in here would trade a real duplication for a fake abstraction. * * MongoDB has no entry: it does not build SQL at all. */ /** How one engine spells identifiers and parameter markers. */ export interface Dialect { /** Quote a table or column name for this engine. */ quote(name: string): string; /** * The parameter marker for the 1-based position `index`. Engines with * positional markers ($1, @p1) use the index; the rest ignore it. */ marker(index: number): string; } /** SQLite, and ODBC which follows the SQL standard spelling. */ export declare const ANSI_DIALECT: Dialect; /** PostgreSQL: standard quoting, positional $N markers. */ export declare const POSTGRES_DIALECT: Dialect; /** MySQL: backtick quoting. */ export declare const MYSQL_DIALECT: Dialect; /** MSSQL: bracket quoting, named @pN markers. */ export declare const MSSQL_DIALECT: Dialect; /** * Firebird quotes only when it has to: an unquoted identifier is folded to * UPPER CASE, so quoting a lower-case name would make it unfindable. The * adapter owns that rule and passes its own quoter in. */ export declare function firebirdDialect(fbQuote: (name: string) => string): Dialect; /** * `INSERT INTO () VALUES ()`. * * @param suffix Appended verbatim - PostgreSQL passes " RETURNING *" and MSSQL * its SCOPE_IDENTITY() probe, the genuinely engine-specific parts. * @param startAt Position of the FIRST marker. PostgreSQL numbers its `$N` from * 1; MSSQL names its `@pN` from 0 and BINDS by that same name, so * shifting it would produce SQL whose parameters do not exist. * Engines using `?` ignore this. */ export declare function buildInsert(dialect: Dialect, table: string, keys: string[], suffix?: string, startAt?: number): string; /** * The `SET a = ?, b = ?` fragment of an UPDATE. * * @param startAt 1-based position of the FIRST marker. An UPDATE's WHERE * clause continues the numbering after the SET values, so a * positional engine ($N, @pN) must not restart at 1. */ export declare function buildSetClause(dialect: Dialect, keys: string[], startAt?: number): string; /** * The `a = ? AND b = ?` fragment for an object filter. * * @param startAt 1-based position of the first marker, for the same reason as * buildSetClause. */ export declare function buildWhereClause(dialect: Dialect, keys: string[], startAt?: number): string;