import { DataSet } from '../../DataSet'; import { ArrayContainsCondition, Condition, ConditionGroup } from '../conditions'; import { DeleteQuery } from '../DeleteQuery'; import { Join, OrderByField, SelectField } from '../features'; import { Field } from '../fields'; import { InsertQuery } from '../InsertQuery'; import { Query } from '../Query'; import { QueryTable } from '../QueryTable'; import { SelectQuery } from '../SelectQuery'; import { Statement } from '../Statement'; import { UpdateQuery } from '../UpdateQuery'; import { UpsertQuery } from '../UpsertQuery'; import { QueryBuilder } from './QueryBuilder'; export declare class DefaultQueryBuilder extends QueryBuilder { protected static readonly SPACE = " "; protected static readonly COMMA = ","; protected static readonly DOUBLE_QUOTES = "\""; protected static readonly EQUALS = "="; protected static readonly PARENTHESIS_START = "("; protected static readonly PARENTHESIS_END = ")"; protected static readonly SELECT = "SELECT"; protected static readonly INSERT = "INSERT"; protected static readonly UPDATE = "UPDATE"; protected static readonly DELETE = "DELETE"; protected static readonly INTO = "INTO"; protected static readonly SET = "SET"; protected static readonly VALUES = "VALUES"; protected static readonly DISTINCT = "DISTINCT"; protected static readonly ALL = "*"; protected static readonly AS = "AS"; protected static readonly POINT = "."; protected static readonly FROM = "FROM"; protected static readonly AND = "AND"; protected static readonly OR = "OR"; protected static readonly NULL = "NULL"; protected static readonly IS = "IS"; protected static readonly NOT = "NOT"; protected static readonly ON = "ON"; protected static readonly WHERE = "WHERE"; protected static readonly EXISTS = "EXISTS"; protected static readonly HAVING = "HAVING"; protected static readonly GROUP = "GROUP"; protected static readonly ORDER = "ORDER"; protected static readonly BY = "BY"; protected static readonly LIMIT = "LIMIT"; protected static readonly OFFSET = "OFFSET"; protected static readonly ASC = "ASC"; protected static readonly DESC = "DESC"; protected static readonly JOIN = "JOIN"; protected static readonly INNER = "INNER"; protected static readonly OUTER = "OUTER"; protected static readonly LEFT = "LEFT"; protected static readonly RIGHT = "RIGHT"; protected static readonly CROSS = "CROSS"; protected static readonly WILDCARD = "?"; protected static readonly UNION = "UNION"; protected static readonly BETWEEN = "BETWEEN"; protected static readonly ON_CONFLICT = "ON CONFLICT"; protected static readonly DO_UPDATE_SET = "DO UPDATE SET"; protected static readonly DO_NOTHING = "DO NOTHING"; protected static readonly EXCLUDED = "EXCLUDED"; buildQuery(query: Query): Statement; protected buildSelectQuery(query: SelectQuery, statement: Statement): void; protected buildLimitOffset(query: SelectQuery, statement: Statement): void; /** * Resolves the rows an InsertQuery should write: the batch set via setRows() * when present, otherwise the single record set via setFields(). The same * code path serves single and batch inserts, so a one-element batch produces * exactly the SQL a single insert used to. */ protected collectInsertRows(query: InsertQuery): DataSet[]; protected buildInsertQuery(query: InsertQuery, statement: Statement): void; protected buildUpdateQuery(query: UpdateQuery, statement: Statement): void; protected buildDeleteQuery(query: DeleteQuery, statement: Statement): void; /** * Builds an upsert (insert-or-update) statement. The INSERT ... VALUES part is * shared across engines; the conflict-resolution clause is delegated to * buildUpsertConflictClause, which engine-specific builders override. */ protected buildUpsertQuery(query: UpsertQuery, statement: Statement): void; /** * Resolves the columns updated on conflict: the explicit list when provided, * otherwise every inserted column that is not part of the conflict target * (Eloquent's default behaviour). */ protected resolveUpsertUpdateColumns(query: UpsertQuery, columns: string[]): string[]; /** * Conflict-resolution clause for PostgreSQL and SQLite, which share the * `ON CONFLICT (...) DO UPDATE SET col = EXCLUDED.col` syntax. MySQL overrides * this with its `ON DUPLICATE KEY UPDATE` form. */ protected buildUpsertConflictClause(query: UpsertQuery, columns: string[], statement: Statement): void; /** Collects the ordered, de-duplicated set of columns present across all rows. */ protected collectUpsertColumns(rows: DataSet[]): string[]; /** * Outputs a plain identifier (column name). Override in engine-specific * subclasses to add quoting (e.g. backticks for MySQL). */ protected buildFieldName(name: string, statement: Statement): void; /** * Parses and outputs a raw string field, supporting: * - 'field' → plain identifier * - 'table.field' → quoted table + field (engine-aware) * - 'FUNC(field)' → function call, field parsed recursively * - 'FUNC(table.field)' → function call with qualified field * - Any string with spaces is treated as a raw SQL expression and * passed through as-is (e.g. 'COUNT(*) AS total'). */ protected buildRawFieldString(raw: string, statement: Statement): void; protected buildSelectField(field: SelectField, statement: Statement): void; protected buildOrderByField(field: OrderByField, statement: Statement): void; protected buildField(field: Field, statement: Statement): void; protected buildCondition(condition: Condition, statement: Statement): void; /** * Array-membership predicate. The default (PostgreSQL) form uses the `@>` * containment operator against an `ARRAY[...]` literal, which is able to use a * GIN index on the column. SQLite/MySQL override this with their own JSON idiom. * * The `ARRAY[...]` literal is cast to `int[]` because the driver binds the * value as an untyped parameter (which PostgreSQL treats as `text`); without * the cast `integer[] @> text[]` fails with "operator does not exist". neorm's * only array column type is `integerArray`, so `int[]` is always the right type. */ protected buildArrayContainsCondition(condition: ArrayContainsCondition, statement: Statement): void; protected buildConditionGroup(conditionGroup: ConditionGroup, statement: Statement): void; protected buildJoin(join: Join, statement: Statement): void; protected buildTable(table: QueryTable, statement: Statement): void; protected buildValue(value: any, statement: Statement): void; /** * Builds a column value for INSERT/UPDATE statements. * * Unlike buildValue, arrays are treated as a single opaque binding and are * never expanded into a list of placeholders. This lets the underlying driver * (e.g. node-postgres) serialize native array types (INT[], TEXT[], JSONB…) * correctly without interference from the query builder. */ protected buildColumnValue(value: any, statement: Statement): void; protected buildArrayValue(value: Array, statement: Statement): void; protected buildSingleValue(value: any, statement: Statement): void; protected buildOperator(operator: string, statement: Statement): void; }