Baseinterfaceno test imports itinterface BaseWhat every node has: where its text is.
| Member | Type | What it is |
|---|---|---|
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
The syntax tree of SQL (commons lang-sql 0002-sql-ast-parser FR-001 to FR-007): a closed union of nodes told apart by kind, each child field typed with the sort of node it may hold, so that a node of the wrong sort in a place does not compile and a switch on kind that leaves a kind out does not compile either. Every node holds start and end, the half-open range of its text in UTF-16 units, and nothing else about where it is: no parent and no text.
Every field of a node is always present (an absent child is undefined, an absent list is empty), so that all nodes of a kind have one shape. The tree is that of the common ground of SQL: what a dialect writes beyond it is read as one of these kinds (operator, a like with its word), never a kind that only one dialect has.
function columns(e: Expr): number {
switch (e.kind) {
case "name": return 1;
case "binary": return columns(e.left) + columns(e.right);
default: return 0;
}
}Spec: 0002-sql-ast-parser FR-001, FR-002, FR-003, FR-004, FR-005, FR-006, FR-007
Baseinterfaceno test imports itinterface BaseWhat every node has: where its text is.
| Member | Type | What it is |
|---|---|---|
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Identinterfaceinterface Ident extends BaseAn identifier: its text without the quotes, a doubled closing quote made one.
| Member | Type | What it is |
|---|---|---|
kind | "ident" | |
name | string | |
quoted | boolean | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Nameinterfaceinterface Name extends BaseA qualified name: a, a.b, a.b.c.
| Member | Type | What it is |
|---|---|---|
kind | "name" | |
parts | readonly Ident[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Starinterfaceno test imports itinterface Star extends BaseA star, with the qualifier it has: *, t.*.
| Member | Type | What it is |
|---|---|---|
kind | "star" | |
qualifier | Name | undefined | |
modifiers | readonly StarModifier[] | What follows the star: EXCEPT (a), EXCLUDE (a), REPLACE (x AS a), RENAME (a AS b), in the order written. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
StarModifierinterfaceno test imports itinterface StarModifier extends BaseA modifier of a star: its keyword (upper case) and its items (a plain column is an item without an alias).
| Member | Type | What it is |
|---|---|---|
kind | "star-modifier" | |
keyword | string | |
items | readonly SelectItem[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
NumberLitinterfaceno test imports itinterface NumberLit extends BaseA number, as written.
| Member | Type | What it is |
|---|---|---|
kind | "number" | |
text | string | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
StringLitinterfaceno test imports itinterface StringLit extends BaseA string, its value as the dialect reads it, and the prefix before its quote (E, N, X, or empty).
| Member | Type | What it is |
|---|---|---|
kind | "string" | |
value | string | |
prefix | string | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
BoolLitinterfaceno test imports itinterface BoolLit extends BaseTRUE or FALSE.
| Member | Type | What it is |
|---|---|---|
kind | "boolean" | |
value | boolean | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
NullLitinterfaceno test imports itinterface NullLit extends BaseNULL.
| Member | Type | What it is |
|---|---|---|
kind | "null" | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Paraminterfaceno test imports itinterface Param extends BaseA parameter, its style and its text.
| Member | Type | What it is |
|---|---|---|
kind | "param" | |
style | ParamStyle | |
text | string | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
UnaryOptypeno test imports ittype UnaryOp = "-" | "+" | "NOT";The unary operators.
Unaryinterfaceno test imports itinterface Unary extends BaseA unary expression.
| Member | Type | What it is |
|---|---|---|
kind | "unary" | |
op | UnaryOp | |
arg | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
BinaryOptypeno test imports ittype BinaryOp = "+" | "-" | "*" | "/" | "%" | "||" | "=" | "<>" | "!=" | "<" | "<=" | ">" | ">=" | "AND" | "OR";The binary operators of the common ground.
Binaryinterfaceno test imports itinterface Binary extends BaseA binary expression.
| Member | Type | What it is |
|---|---|---|
kind | "binary" | |
op | BinaryOp | |
left | Expr | |
right | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Operatorinterfaceno test imports itinterface Operator extends BaseA binary expression whose operator is the dialect's own, as written.
| Member | Type | What it is |
|---|---|---|
kind | "operator" | |
op | string | |
left | Expr | undefined | Missing for an operator written before its operand (@ x, |/ x). |
right | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
IsTesttypeno test imports ittype IsTest = "null" | "true" | "false" | "unknown" | "distinct-from";What IS tests.
Isinterfaceno test imports itinterface Is extends Basex IS [NOT] NULL | TRUE | FALSE | UNKNOWN | DISTINCT FROM other.
| Member | Type | What it is |
|---|---|---|
kind | "is" | |
arg | Expr | |
test | IsTest | |
negated | boolean | |
other | Expr | undefined | The expression after DISTINCT FROM. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Betweeninterfaceno test imports itinterface Between extends Basex [NOT] BETWEEN low AND high.
| Member | Type | What it is |
|---|---|---|
kind | "between" | |
arg | Expr | |
negated | boolean | |
symmetric | boolean | BETWEEN SYMMETRIC. |
low | Expr | |
high | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Ininterfaceno test imports itinterface In extends Basex [NOT] IN (a, b, ...).
| Member | Type | What it is |
|---|---|---|
kind | "in" | |
arg | Expr | |
negated | boolean | |
values | readonly Expr[] | |
bare | boolean | x IN t, with no parentheses (SQLite): the one value is the table's name. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
InQueryinterfaceno test imports itinterface InQuery extends Basex [NOT] IN (query).
| Member | Type | What it is |
|---|---|---|
kind | "in-query" | |
arg | Expr | |
negated | boolean | |
query | Query | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Likeinterfaceno test imports itinterface Like extends Basex [NOT] LIKE pattern [ESCAPE e]; op is the word, upper case (LIKE, ILIKE, ...).
| Member | Type | What it is |
|---|---|---|
kind | "like" | |
arg | Expr | |
op | string | |
negated | boolean | |
pattern | Expr | |
escape | Expr | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Wheninterfaceno test imports itinterface When extends BaseOne WHEN cond THEN result of a CASE.
| Member | Type | What it is |
|---|---|---|
kind | "when" | |
cond | Expr | |
result | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Caseinterfaceno test imports itinterface Case extends BaseCASE [operand] WHEN ... THEN ... [ELSE e] END.
| Member | Type | What it is |
|---|---|---|
kind | "case" | |
operand | Expr | undefined | |
whens | readonly When[] | |
otherwise | Expr | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Castinterfaceno test imports itinterface Cast extends BaseCAST(x AS type), and x::type where the dialect has it.
| Member | Type | What it is |
|---|---|---|
kind | "cast" | |
arg | Expr | |
type | DataType | |
try | boolean | TRY_CAST and SAFE_CAST, which give NULL where the cast fails. |
format | Expr | undefined | The FORMAT of CAST(x AS type FORMAT 'f'). |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
ExtractFieldinterfaceno test imports itinterface ExtractField extends BaseEXTRACT(field FROM x); the field is upper case.
| Member | Type | What it is |
|---|---|---|
kind | "extract" | |
field | string | |
arg | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Intervalinterfaceno test imports itinterface Interval extends BaseINTERVAL value [unit]; the unit is upper case.
| Member | Type | What it is |
|---|---|---|
kind | "interval" | |
value | Expr | |
unit | string | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
NamedArginterfaceno test imports itinterface NamedArg extends BaseA named argument of a call: name => value, name := value.
| Member | Type | What it is |
|---|---|---|
kind | "named-arg" | |
name | Ident | |
value | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
ArrayLitinterfaceno test imports itinterface ArrayLit extends Base[a, b] and ARRAY[a, b].
| Member | Type | What it is |
|---|---|---|
kind | "array" | |
items | readonly Expr[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Subscriptinterfaceno test imports itinterface Subscript extends Basex[i], and the slice x[i:j] (either end may be missing: x[:j], x[i:]).
| Member | Type | What it is |
|---|---|---|
kind | "subscript" | |
arg | Expr | |
index | Expr | undefined | |
upper | Expr | undefined | The end of a slice. |
slice | boolean | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
FieldAccessinterfaceno test imports itinterface FieldAccess extends BaseA field of a row: (r).c, (r).* (a field of undefined is the star).
| Member | Type | What it is |
|---|---|---|
kind | "field" | |
arg | Expr | |
field | Ident | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
TypedStringinterfaceno test imports itinterface TypedString extends BaseA literal written with its type's name before the string: DATE '2020-01-01', int2 '2'; the type is upper case.
| Member | Type | What it is |
|---|---|---|
kind | "typed-string" | |
type | string | |
value | StringLit | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
KeywordArginterfaceno test imports itinterface KeywordArg extends BaseA keyword argument of a call: the FROM, FOR, IN, PLACING or SIMILAR of SUBSTRING(x FROM 1 FOR 2), the BOTH, LEADING or TRAILING of TRIM, VARIADIC; its value is missing for TRIM(BOTH FROM x)'s BOTH.
| Member | Type | What it is |
|---|---|---|
kind | "keyword-arg" | |
keyword | string | |
value | Expr | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
StructEntryinterfaceno test imports itinterface StructEntry extends BaseOne key: value of a struct or map literal.
| Member | Type | What it is |
|---|---|---|
kind | "struct-entry" | |
key | Expr | |
value | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
StructLitinterfaceno test imports itinterface StructLit extends BaseA struct or map literal: {'a': 1}, map{1: 'x'}; the prefix is the word before the brace, as written.
| Member | Type | What it is |
|---|---|---|
kind | "struct" | |
prefix | string | undefined | |
entries | readonly StructEntry[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Lambdainterfaceno test imports itinterface Lambda extends BaseA lambda: x -> body, (x, y) -> body, lambda x: body.
| Member | Type | What it is |
|---|---|---|
kind | "lambda" | |
params | readonly Ident[] | |
body | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Collateinterfaceno test imports itinterface Collate extends Basex COLLATE name.
| Member | Type | What it is |
|---|---|---|
kind | "collate" | |
arg | Expr | |
collation | Name | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Callinterfaceno test imports itinterface Call extends BaseA call: name(args), with DISTINCT, FILTER (WHERE ...) and OVER.
| Member | Type | What it is |
|---|---|---|
kind | "call" | |
name | Name | |
parameters | readonly Argument[] | The parameters of a parametric call f(p)(args), which are the first parentheses (ClickHouse). |
args | readonly Argument[] | |
distinct | boolean | |
orderBy | readonly OrderItem[] | The ORDER BY among the arguments: string_agg(x, ',' ORDER BY y). |
withinGroup | readonly OrderItem[] | WITHIN GROUP (ORDER BY ...). |
nullTreatment | "ignore" | "respect" | undefined | IGNORE NULLS or RESPECT NULLS after the arguments. |
filter | Expr | undefined | |
over | WindowSpec | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Existsinterfaceno test imports itinterface Exists extends BaseEXISTS (query).
| Member | Type | What it is |
|---|---|---|
kind | "exists" | |
query | Query | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
ScalarQueryinterfaceno test imports itinterface ScalarQuery extends BaseA query used as a value: (SELECT ...).
| Member | Type | What it is |
|---|---|---|
kind | "scalar-query" | |
query | Query | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Tupleinterfaceno test imports itinterface Tuple extends BaseA row: (a, b).
| Member | Type | What it is |
|---|---|---|
kind | "tuple" | |
items | readonly Expr[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Exprtypetype Expr =
| Name
| Star
| NumberLit
| StringLit
| BoolLit
| NullLit
| Param
| Unary
| Binary
| Operator
| Is
| Between
| In
| InQuery
| Like
| Case
| Cast
| ExtractField
| Interval
| ArrayLit
| Subscript
| StructLit
| Lambda
| FieldAccess
| TypedString
| Collate
| Call
| Exists
| ScalarQuery
| Tuple;An expression.
FrameBoundinterfaceno test imports itinterface FrameBound extends BaseOne end of a window frame.
| Member | Type | What it is |
|---|---|---|
kind | "frame-bound" | |
type | "current-row" | "following" | "preceding" | "unbounded-following" | "unbounded-preceding" | |
offset | Expr | undefined | The distance, for n PRECEDING and n FOLLOWING. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Frameinterfaceno test imports itinterface Frame extends BaseA window frame: ROWS | RANGE | GROUPS from one bound, or between two.
| Member | Type | What it is |
|---|---|---|
kind | "frame" | |
unit | "groups" | "range" | "rows" | |
from | FrameBound | |
to | FrameBound | undefined | |
exclude | string | undefined | The EXCLUDE of the frame, upper case: NO OTHERS, CURRENT ROW, GROUP or TIES. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
WindowSpecinterfaceno test imports itinterface WindowSpec extends BaseA window: OVER name, or OVER ([name] [PARTITION BY ...] [ORDER BY ...] [frame]).
| Member | Type | What it is |
|---|---|---|
kind | "window-spec" | |
base | Ident | undefined | |
partitionBy | readonly Expr[] | |
orderBy | readonly OrderItem[] | |
frame | Frame | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
OrderIteminterfaceno test imports itinterface OrderItem extends BaseOne item of an ORDER BY.
| Member | Type | What it is |
|---|---|---|
kind | "order-item" | |
expr | Expr | |
direction | "asc" | "desc" | undefined | |
nulls | "first" | "last" | undefined | |
opclass | string | undefined | The operator class after an index column. |
using | string | undefined | The operator of ORDER BY x USING <. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
WindowDefinterfaceno test imports itinterface WindowDef extends Basename AS (window) of a WINDOW clause.
| Member | Type | What it is |
|---|---|---|
kind | "window-def" | |
name | Ident | |
spec | WindowSpec | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
SelectIteminterfaceno test imports itinterface SelectItem extends BaseOne item of a select list: an expression and its alias.
| Member | Type | What it is |
|---|---|---|
kind | "select-item" | |
expr | Expr | |
alias | Ident | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Selectinterfaceinterface Select extends BaseSELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY ... LIMIT ... OFFSET ....
| Member | Type | What it is |
|---|---|---|
kind | "select" | |
distinct | boolean | |
top | Expr | undefined | TOP n [PERCENT] [WITH TIES] after SELECT (T-SQL): the count, and the words after it as text. |
topOptions | string | undefined | |
into | string | undefined | The INTO after the items (SELECT * INTO TABLE t), as text. |
items | readonly SelectItem[] | |
from | readonly Source[] | |
where | Expr | undefined | |
distinctOn | readonly Expr[] | The expressions of DISTINCT ON (...). |
groupBy | readonly Expr[] | |
groupAll | boolean | GROUP BY ALL. |
having | Expr | undefined | |
windows | readonly WindowDef[] | The named windows of WINDOW w AS (...). |
qualify | Expr | undefined | |
orderBy | readonly OrderItem[] | |
limit | Expr | undefined | |
limitOptions | string | undefined | The words of FETCH FIRST n [PERCENT] ROWS ONLY | WITH TIES that a LIMIT cannot say, as text (PERCENT, WITH TIES, PERCENT WITH TIES); none for a count of rows only. |
offset | Expr | undefined | |
locking | string | undefined | The locking clauses (FOR UPDATE OF t NOWAIT), as text. |
settings | string | undefined | The clauses after the query that the dialect names in its grammar's queryTail (SETTINGS a = 1 FORMAT JSON), as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
SetOperatortypeno test imports ittype SetOperator = "union" | "intersect" | "except";UNION, INTERSECT or EXCEPT.
SetOpinterfaceno test imports itinterface SetOp extends BaseTwo queries combined; the ORDER BY, LIMIT and OFFSET that follow it are its own.
| Member | Type | What it is |
|---|---|---|
kind | "set-op" | |
op | SetOperator | |
byName | boolean | BY NAME: columns are matched by name (DuckDB). |
quantifier | "all" | "distinct" | undefined | |
left | Query | |
right | Query | |
orderBy | readonly OrderItem[] | |
limit | Expr | undefined | |
limitOptions | string | undefined | The words of FETCH FIRST n [PERCENT] ROWS ONLY | WITH TIES that a LIMIT cannot say, as text; none for a count of rows only. |
offset | Expr | undefined | |
locking | string | undefined | The locking clauses (FOR UPDATE OF t NOWAIT), as text. |
settings | string | undefined | The clauses after the query that the dialect names in its grammar's queryTail (SETTINGS a = 1 FORMAT JSON), as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Valuesinterfaceno test imports itinterface Values extends BaseVALUES (...), (...).
| Member | Type | What it is |
|---|---|---|
kind | "values" | |
rows | readonly Tuple[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Cteinterfaceno test imports itinterface Cte extends BaseOne common table expression: name [(columns)] AS (query).
| Member | Type | What it is |
|---|---|---|
kind | "cte" | |
name | Ident | |
columns | readonly Ident[] | |
query | CteBody | |
materialized | "materialized" | "not-materialized" | undefined | MATERIALIZED or NOT MATERIALIZED, where written. |
trailer | string | undefined | The SEARCH or CYCLE clause after it, as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Withinterfaceno test imports itinterface With extends BaseWITH [RECURSIVE] ctes body.
| Member | Type | What it is |
|---|---|---|
kind | "with" | |
recursive | boolean | |
ctes | readonly Cte[] | |
body | CteBody | What follows: a query, or a data change (WITH x AS (...) INSERT ...). |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
CteBodytypeno test imports ittype CteBody = Query | Insert | Update | Delete;What a common table expression or a WITH holds: a query, or a data change (WITH x AS (INSERT ... RETURNING *) ...).
Querytypetype Query = Select | SetOp | Values | With;A query.
Aliasinterfaceno test imports itinterface Alias extends BaseThe alias of a source: AS name [(columns)].
| Member | Type | What it is |
|---|---|---|
kind | "alias" | |
name | Ident | |
columns | readonly Ident[] | |
types | readonly (DataType | undefined)[] | The types of a list of column definitions (AS t (a int, b text)), in the order of the columns; an entry is missing for a column written without one. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
TableRefinterfaceinterface TableRef extends BaseA table named in FROM, with its alias.
| Member | Type | What it is |
|---|---|---|
kind | "table" | |
name | Name | |
alias | Alias | undefined | |
hint | string | undefined | What stands beside the table and is not read: ONLY before it, * or NOT INDEXED, INDEXED BY i or TABLESAMPLE ... after it, as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
SubquerySourceinterfaceno test imports itinterface SubquerySource extends BaseA query used as a source: [LATERAL] (query) [alias].
| Member | Type | What it is |
|---|---|---|
kind | "subquery" | |
query | Query | |
alias | Alias | undefined | |
lateral | boolean | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
TableFninterfaceno test imports itinterface TableFn extends BaseA function used as a source: [LATERAL] fn(args) [alias].
| Member | Type | What it is |
|---|---|---|
kind | "table-fn" | |
call | Call | |
alias | Alias | undefined | |
lateral | boolean | |
ordinality | boolean | WITH ORDINALITY. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
JoinTypetypeno test imports ittype JoinType = "inner" | "left" | "right" | "full" | "cross" | "semi" | "anti" | "cross-apply" | "outer-apply";The types of join.
Joininterfaceno test imports itinterface Join extends BaseA join of two sources, with ON or USING.
| Member | Type | What it is |
|---|---|---|
kind | "join" | |
type | JoinType | |
natural | boolean | |
left | Source | |
right | Source | |
on | Expr | undefined | |
using | readonly Ident[] | |
usingAlias | Ident | undefined | The alias of the USING list: JOIN t USING (i) AS x. |
alias | Alias | undefined | The alias of a parenthesized join: (a JOIN b ON ...) AS t. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
TableOpinterfaceno test imports itinterface TableOp extends BaseAn operator applied to a source that the grammar keeps as text: PIVOT (...), UNPIVOT (...), MATCH_RECOGNIZE (...), LATERAL VIEW ...; text runs from the operator's word to its end, and the alias is the one after it.
| Member | Type | What it is |
|---|---|---|
kind | "table-op" | |
op | string | |
source | Source | |
text | string | |
alias | Alias | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Sourcetypetype Source = TableRef | SubquerySource | TableFn | Join | TableOp;A source of rows.
Insertinterfaceno test imports itinterface Insert extends BaseINSERT INTO table [(columns)] query | DEFAULT VALUES [RETURNING ...]; a source of undefined is DEFAULT VALUES.
| Member | Type | What it is |
|---|---|---|
kind | "insert" | |
partition | string | undefined | PARTITION (...) after the table (Hive), as text. |
byName | boolean | INSERT INTO t BY NAME (DuckDB). |
table | Name | |
alias | Ident | undefined | The alias of the table (INSERT INTO t AS x). |
columns | readonly Expr[] | The columns: names, or parts of them (a[1], r.f). |
source | Query | undefined | |
conflict | string | undefined | The OR of INSERT OR REPLACE, or REPLACE for REPLACE INTO, upper case. |
onConflict | OnConflict | undefined | |
returning | readonly SelectItem[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
OnConflictinterfaceno test imports itinterface OnConflict extends BaseON CONFLICT [(target) | ON CONSTRAINT name] [WHERE ...] DO NOTHING | DO UPDATE SET ... [WHERE ...].
| Member | Type | What it is |
|---|---|---|
kind | "on-conflict" | |
duplicateKey | boolean | Written ON DUPLICATE KEY UPDATE (MySQL) and not ON CONFLICT. |
targets | readonly Expr[] | |
constraint | Ident | undefined | |
targetWhere | Expr | undefined | |
update | boolean | Whether the action is DO UPDATE (and not DO NOTHING). |
assignments | readonly Assignment[] | |
where | Expr | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Assignmentinterfaceno test imports itinterface Assignment extends BaseOne target = value of an UPDATE.
| Member | Type | What it is |
|---|---|---|
kind | "assignment" | |
target | Expr | The column, or a part of one (a[1], r.f), or a row of columns ((a, b)). |
value | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Updateinterfaceno test imports itinterface Update extends BaseUPDATE table SET ... [FROM ...] [WHERE ...] [RETURNING ...].
| Member | Type | What it is |
|---|---|---|
kind | "update" | |
table | TableRef | |
assignments | readonly Assignment[] | |
from | readonly Source[] | |
where | Expr | undefined | |
returning | readonly SelectItem[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Deleteinterfaceno test imports itinterface Delete extends BaseDELETE FROM table [WHERE ...] [RETURNING ...].
| Member | Type | What it is |
|---|---|---|
kind | "delete" | |
table | TableRef | |
using | readonly Source[] | The sources of USING. |
where | Expr | undefined | |
returning | readonly SelectItem[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
DataTypeinterfaceno test imports itinterface DataType extends BaseA data type: its words, upper case, joined by a space (DOUBLE PRECISION, TIMESTAMP WITH TIME ZONE, INTEGER[]), and its arguments.
| Member | Type | What it is |
|---|---|---|
kind | "data-type" | |
name | string | |
args | readonly Expr[] | |
fields | readonly TypeField[] | The fields or parameters of a type that names them: STRUCT(a INT, b TEXT), ARRAY<INT>, MAP<K, V>. |
charset | string | undefined | The name of its CHARACTER SET, as written. |
collation | string | undefined | The name of its COLLATE, as written. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
TypeFieldinterfaceno test imports itinterface TypeField extends BaseA field of a type that has fields: its name (missing in ARRAY<INT>) and its type.
| Member | Type | What it is |
|---|---|---|
kind | "type-field" | |
name | Ident | undefined | |
type | DataType | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
NotNullinterfaceno test imports itinterface NotNull extends Base[CONSTRAINT name] NOT NULL.
| Member | Type | What it is |
|---|---|---|
kind | "not-null" | |
name | Ident | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Defaultinterfaceno test imports itinterface Default extends Base[CONSTRAINT name] DEFAULT expr.
| Member | Type | What it is |
|---|---|---|
kind | "default" | |
name | Ident | undefined | |
expr | Expr | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
PrimaryKeyinterfaceno test imports itinterface PrimaryKey extends Base[CONSTRAINT name] PRIMARY KEY [(columns)]; the columns are empty on a column.
| Member | Type | What it is |
|---|---|---|
kind | "primary-key" | |
name | Ident | undefined | |
columns | readonly Ident[] | |
options | string | undefined | DEFERRABLE, INITIALLY DEFERRED, NOT ENFORCED and the like after it, as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Uniqueinterfaceno test imports itinterface Unique extends Base[CONSTRAINT name] UNIQUE [(columns)]; the columns are empty on a column.
| Member | Type | What it is |
|---|---|---|
kind | "unique" | |
name | Ident | undefined | |
columns | readonly Ident[] | |
options | string | undefined | DEFERRABLE, INITIALLY DEFERRED, NOT ENFORCED and the like after it, as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Checkinterfaceno test imports itinterface Check extends Base[CONSTRAINT name] CHECK (expr).
| Member | Type | What it is |
|---|---|---|
kind | "check" | |
name | Ident | undefined | |
expr | Expr | |
options | string | undefined | NO INHERIT or NOT VALID after it, as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
RefActiontypeno test imports ittype RefAction = "cascade" | "restrict" | "set-null" | "set-default" | "no-action";What a foreign key does when the row it refers to changes.
Referenceinterfaceno test imports itinterface Reference extends BaseREFERENCES table [(columns)] [ON DELETE action] [ON UPDATE action].
| Member | Type | What it is |
|---|---|---|
kind | "reference" | |
table | Name | |
columns | readonly Ident[] | |
onDelete | RefAction | undefined | |
onUpdate | RefAction | undefined | |
options | string | undefined | What follows (MATCH FULL, NOT DEFERRABLE, DEFERRABLE INITIALLY DEFERRED), as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
ForeignKeyinterfaceno test imports itinterface ForeignKey extends Base[CONSTRAINT name] [FOREIGN KEY (columns)] REFERENCES ...; the columns are empty on a column.
| Member | Type | What it is |
|---|---|---|
kind | "foreign-key" | |
name | Ident | undefined | |
columns | readonly Ident[] | |
reference | Reference | |
options | string | undefined | DEFERRABLE, INITIALLY DEFERRED, NOT ENFORCED and the like after it, as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
ColumnConstrainttypeno test imports ittype ColumnConstraint = NotNull | Default | PrimaryKey | Unique | Check | ForeignKey | ColumnOption;A constraint of a column.
ColumnOptioninterfaceno test imports itinterface ColumnOption extends BaseAn option of a column that the grammar does not read apart (AUTOINCREMENT, UNSIGNED, GENERATED ALWAYS AS (expr) STORED), as text, with the expression of AS (expr) where there is one.
| Member | Type | What it is |
|---|---|---|
kind | "column-option" | |
name | Ident | undefined | |
text | string | |
expr | Expr | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
TableLikeinterfaceno test imports itinterface TableLike extends BaseLIKE table [INCLUDING ...] among the elements of a CREATE TABLE; the options are text.
| Member | Type | What it is |
|---|---|---|
kind | "table-like" | |
table | Name | |
options | string | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
TableConstrainttypeno test imports ittype TableConstraint = PrimaryKey | Unique | Check | ForeignKey | TableLike | ColumnOption;A constraint of a table.
ColumnDefinterfaceno test imports itinterface ColumnDef extends BaseA column of a table: its name, type and constraints.
| Member | Type | What it is |
|---|---|---|
kind | "column-def" | |
name | Ident | |
type | DataType | |
constraints | readonly ColumnConstraint[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
CreateTableinterfaceno test imports itinterface CreateTable extends BaseCREATE TABLE [IF NOT EXISTS] name (columns and constraints); the elements are in the order of the text.
| Member | Type | What it is |
|---|---|---|
kind | "create-table" | |
name | Name | |
ifNotExists | boolean | |
temporary | boolean | Whether it is TEMP or TEMPORARY. |
elements | readonly (ColumnDef | TableConstraint)[] | |
query | Query | undefined | The query of AS query, for a table made from one. |
options | string | undefined | The text after the column list or the name that the parser does not read (an engine, partitions, options), as written. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
CreateIndexinterfaceno test imports itinterface CreateIndex extends BaseCREATE [UNIQUE] INDEX [IF NOT EXISTS] [name] ON table (items) [WHERE ...].
| Member | Type | What it is |
|---|---|---|
kind | "create-index" | |
unique | boolean | |
concurrently | boolean | |
ifNotExists | boolean | |
name | Name | undefined | |
only | boolean | ON ONLY table. |
table | Name | |
items | readonly OrderItem[] | |
where | Expr | undefined | |
method | string | undefined | The method of USING method, as written. |
options | string | undefined | What follows the columns (INCLUDE (...), WITH (...), NULLS NOT DISTINCT), as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
CreateViewinterfaceno test imports itinterface CreateView extends BaseCREATE [OR REPLACE] VIEW name [(columns)] AS query.
| Member | Type | What it is |
|---|---|---|
kind | "create-view" | |
orReplace | boolean | |
name | Name | |
columns | readonly Ident[] | |
options | string | undefined | The WITH (...) before AS, as text. |
query | Query | |
checkOption | string | undefined | The WITH CHECK OPTION after the query, as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
AddColumninterfaceno test imports itinterface AddColumn extends BaseADD [COLUMN] [IF NOT EXISTS] column.
| Member | Type | What it is |
|---|---|---|
kind | "add-column" | |
ifNotExists | boolean | |
column | ColumnDef | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
DropColumninterfaceno test imports itinterface DropColumn extends BaseDROP [COLUMN] [IF EXISTS] name.
| Member | Type | What it is |
|---|---|---|
kind | "drop-column" | |
ifExists | boolean | |
name | Ident | |
behavior | "cascade" | "restrict" | undefined | CASCADE or RESTRICT, where written. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
AddConstraintinterfaceno test imports itinterface AddConstraint extends BaseADD constraint.
| Member | Type | What it is |
|---|---|---|
kind | "add-constraint" | |
constraint | TableConstraint | |
options | string | undefined | NOT VALID, as text. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
DropConstraintinterfaceno test imports itinterface DropConstraint extends BaseDROP CONSTRAINT [IF EXISTS] name.
| Member | Type | What it is |
|---|---|---|
kind | "drop-constraint" | |
ifExists | boolean | |
name | Ident | |
behavior | "cascade" | "restrict" | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
RenameTableinterfaceno test imports itinterface RenameTable extends BaseRENAME TO name.
| Member | Type | What it is |
|---|---|---|
kind | "rename-table" | |
to | Ident | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
RenameColumninterfaceno test imports itinterface RenameColumn extends BaseRENAME [COLUMN] from TO to.
| Member | Type | What it is |
|---|---|---|
kind | "rename-column" | |
from | Ident | |
to | Ident | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
AlterActiontypeno test imports ittype AlterAction = AddColumn | DropColumn | AddConstraint | DropConstraint | RenameTable | RenameColumn;One action of an ALTER TABLE.
AlterTableinterfaceno test imports itinterface AlterTable extends BaseALTER TABLE [IF EXISTS] name action [, action ...].
| Member | Type | What it is |
|---|---|---|
kind | "alter-table" | |
ifExists | boolean | |
table | Name | |
actions | readonly AlterAction[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Dropinterfaceno test imports itinterface Drop extends BaseDROP TABLE | VIEW | INDEX [IF EXISTS] names [CASCADE | RESTRICT].
| Member | Type | What it is |
|---|---|---|
kind | "drop" | |
object | "index" | "table" | "view" | |
ifExists | boolean | |
names | readonly Name[] | |
concurrently | boolean | |
behavior | "cascade" | "restrict" | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
RoutineParaminterfaceno test imports itinterface RoutineParam extends BaseA parameter of a routine.
| Member | Type | What it is |
|---|---|---|
kind | "routine-param" | |
mode | "in" | "inout" | "out" | "variadic" | undefined | |
name | Ident | undefined | |
type | DataType | |
default | Expr | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
BodyStyletypeno test imports ittype BodyStyle = "dollar" | "string" | "block" | "return" | "external";How a routine's body is written.
RoutineBodyinterfaceno test imports itinterface RoutineBody extends BaseThe body of a routine: its style, its text, and where the text is in the whole text.
| Member | Type | What it is |
|---|---|---|
kind | "routine-body" | |
style | BodyStyle | |
text | string | The text between its delimiters; for a string body, the string's value. |
bodyStart | number | Where the text begins in the whole text. |
bodyEnd | number | Where the text ends in the whole text. |
exact | boolean | Whether the source between bodyStart and bodyEnd is text: false where a string body has escapes. |
expr | Expr | undefined | The expression of RETURN expression. |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
CreateRoutineinterfaceno test imports itinterface CreateRoutine extends BaseCREATE [OR REPLACE] FUNCTION | PROCEDURE name (parameters) ...: its header and its body.
| Member | Type | What it is |
|---|---|---|
kind | "create-routine" | |
object | "function" | "procedure" | |
orReplace | boolean | |
name | Name | |
params | readonly RoutineParam[] | |
returns | DataType | undefined | |
setof | boolean | |
table | readonly ColumnDef[] | The columns of RETURNS TABLE (...). |
language | string | undefined | The language, lower case. |
options | string | undefined | The other characteristics as written (IMMUTABLE, SECURITY DEFINER, COST 10). |
body | RoutineBody | undefined | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Commandinterfaceno test imports itinterface Command extends BaseA statement of a kind the grammar does not read: a command (SET, SHOW, EXPLAIN, GRANT, ...) or a CREATE, ALTER or DROP of an object it does not read (a function, a sequence, a type). It holds no node: its keyword and, for those three, its object, upper case, and the text after them as written.
| Member | Type | What it is |
|---|---|---|
kind | "command" | |
keyword | string | |
object | string | undefined | |
text | string | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Unparsedinterfaceno test imports itinterface Unparsed extends BaseA statement the parser could not read: its range, from its first token to the one before the ; that ends it.
| Member | Type | What it is |
|---|---|---|
kind | "unparsed" | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Statementtypetype Statement =
Query | Insert | Update | Delete | CreateTable | CreateIndex | CreateView | AlterTable | Drop | CreateRoutine | Command | Unparsed;A statement.
Scriptinterfaceinterface Script extends BaseA script: its statements.
| Member | Type | What it is |
|---|---|---|
kind | "script" | |
statements | readonly Statement[] | |
start | number | Where its text begins. |
end | number | Where its text ends, exclusive. |
Nodetypetype Node =
| Ident
| Expr
| Argument
| FrameBound
| Frame
| WindowSpec
| WindowDef
| StarModifier
| O… (402 characters)type Node =
| Ident
| Expr
| Argument
| FrameBound
| Frame
| WindowSpec
| WindowDef
| StarModifier
| OnConflict
| StructEntry
| TypeField
| TableLike
| OrderItem
| When
| SelectItem
| Query
| Cte
| Alias
| Source
| Assignment
| DataType
| ColumnConstraint
| Reference
| ColumnDef
| RoutineParam
| RoutineBody
| Statement
| AlterAction
| Script;Every node.
Argumenttypeno test imports ittype Argument = Expr | NamedArg | KeywordArg;An argument of a call.
Kindtypeno test imports ittype Kind = Node["kind"];The kinds of node.
NodeOftypeno test imports ittype NodeOf<K extends Kind> = Extract<Node, { readonly kind: K }>;The node of a kind.