From c19bfb009860d4ccd46b5bafdd4cff2b0baf8864 Mon Sep 17 00:00:00 2001 From: taozhi8833998 Date: Mon, 25 Dec 2023 19:14:45 +0800 Subject: [PATCH] refactor: update type definition --- ast/postgresql.ts | 10 +++++++++- pegjs/postgresql.pegjs | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ast/postgresql.ts b/ast/postgresql.ts index 0d88e65d..16a48f53 100644 --- a/ast/postgresql.ts +++ b/ast/postgresql.ts @@ -827,6 +827,8 @@ export type join_op = 'LEFT JOIN' | 'RIGHT JOIN' | 'FULL JOIN' | 'CROSS JOIN' | export type table_name = { db?: ident; schema?: ident, table: ident | '*'; }; +export type or_and_expr = binary_expr; + export type on_clause = or_and_where_expr; @@ -1171,7 +1173,7 @@ export type concat_separator = { keyword: string | null; value: literal_string; -export type distinct_args = { distinct: 'DISTINCT'; expr: expr; orderby?: order_by_clause; parentheses: boolean; separator?: concat_separator; }; +export type distinct_args = { distinct: 'DISTINCT'; expr: expr; orderby?: order_by_clause; separator?: concat_separator; }; @@ -1216,6 +1218,12 @@ export type cast_double_colon = { export type cast_expr = { + type: 'cast'; + expr: or_expr | column_ref | param + | expr; + keyword: 'cast'; + ...cast_double_colon; + } | { type: 'cast'; expr: literal | aggr_func | func_call | case_expr | interval_expr | column_ref | param | expr; diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 8c86224d..53868314 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -3124,6 +3124,7 @@ table_name or_and_expr = head:expr tail:(__ (KW_AND / KW_OR) __ expr)* { + // => binary_expr const len = tail.length let result = head for (let i = 0; i < len; ++i) {