Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,44 +64,47 @@ export interface AggrFunc {
args: ColumnRef | AggrFunc | Star | null;
}
export interface Function {
type: 'function';
type: "function";
name: string;
args: expr_list;
args: ExprList;
suffix?: any;
}
export interface Column {
expr: ColumnRef | AggrFunc | Function;
as: string;
as: string | null;
type?: string;
}

type Param = { type: 'param'; value: string };
type Param = { type: "param"; value: string };

type Value = { type: string; value: any };

export type Expr =
| {
type: 'binary_expr';
operator: 'AND' | 'OR';
type: "binary_expr";
operator: "AND" | "OR";
left: Expr;
right: Expr;
}
| {
type: 'binary_expr';
type: "binary_expr";
operator: string;
left: ColumnRef | Param;
right: ColumnRef | Param;
left: ColumnRef | Param | Value;
right: ColumnRef | Param | Value;
};

export type expr_list = {
type: 'expr_list';
export type ExprList = {
type: "expr_list";
value: Expr[];
}
};
export interface Select {
with: With | null;
type: "select";
options: any[] | null;
distinct: "DISTINCT" | null;
columns: any[] | Column[];
from: Array<From | Dual | any> | null;
where: Expr;
where: Expr | Function | null;
groupby: ColumnRef[] | null;
having: any[] | null;
orderby: OrderBy[] | null;
Expand All @@ -123,18 +126,18 @@ export interface Update {
db: string | null;
table: Array<From | Dual> | null;
set: SetList[];
where: Expr;
where: Expr | Function | null;
}
export interface Delete {
type: "delete";
table: any;
from: Array<From | Dual>;
where: Expr;
where: Expr | Function | null;
}

export interface Alter {
type: "alter";
table: From;
table: From[];
expr: any;
}

Expand Down Expand Up @@ -185,14 +188,21 @@ export interface Create {
database?: string;
}

export interface Drop {
type: "drop";
keyword: string;
name: any[];
}

export type AST =
| Use
| Select
| Insert_Replace
| Update
| Delete
| Alter
| Create;
| Create
| Drop;

export class Parser {
constructor();
Expand Down