All files / src/sql ast-expressions.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                                                                                         
import type { QueryNode } from './ast-statements.ts';
 
export type ParamNode = Readonly<{ kind: 'param'; value: unknown }>;
export type RawNode = Readonly<{ kind: 'raw'; sql: string }>;
export type IdentNode = Readonly<{ kind: 'ident'; path: readonly string[] }>;
export type StarNode = Readonly<{ kind: 'star'; table?: string }>;
export type FnNode = Readonly<{
  kind: 'fn';
  name: string;
  args: readonly ExprNode[];
  distinct?: boolean;
}>;
export type CastNode = Readonly<{ kind: 'cast'; expr: ExprNode; type: string }>;
export type BinaryNode = Readonly<{ kind: 'binary'; op: string; left: ExprNode; right: ExprNode }>;
export type PrefixNode = Readonly<{ kind: 'prefix'; op: string; expr: ExprNode }>;
export type PostfixNode = Readonly<{ kind: 'postfix'; op: string; expr: ExprNode }>;
export type LogicalNode = Readonly<{ kind: 'and' | 'or'; items: readonly ExprNode[] }>;
export type ListNode = Readonly<{ kind: 'list'; items: readonly ExprNode[] }>;
export type BetweenNode = Readonly<{
  kind: 'between';
  expr: ExprNode;
  low: ExprNode;
  high: ExprNode;
  negated: boolean;
}>;
export type ExcludedNode = Readonly<{ kind: 'excluded'; column: string }>;
export type SubqueryNode = Readonly<{ kind: 'subquery'; query: QueryNode }>;
export type AliasNode = Readonly<{ kind: 'alias'; expr: ExprNode; alias: string }>;
export type OverNode = Readonly<{
  kind: 'over';
  expr: ExprNode;
  partitionBy: readonly ExprNode[];
  orderBy: readonly OrderNode[];
}>;
export type ValuesNode = Readonly<{ kind: 'values'; rows: readonly (readonly ExprNode[])[] }>;
 
export type ExprNode =
  | ParamNode
  | RawNode
  | IdentNode
  | StarNode
  | FnNode
  | CastNode
  | BinaryNode
  | PrefixNode
  | PostfixNode
  | LogicalNode
  | ListNode
  | BetweenNode
  | ExcludedNode
  | SubqueryNode
  | AliasNode
  | ValuesNode
  | OverNode;
 
export type OrderNode = Readonly<{
  expr: ExprNode;
  direction?: 'ASC' | 'DESC';
  nulls?: 'FIRST' | 'LAST';
}>;