From 77db53a8efdb56dbd19cf88b17c07f9f25b9f7db Mon Sep 17 00:00:00 2001 From: taozhi8833998 Date: Wed, 8 May 2024 19:59:28 +0800 Subject: [PATCH] fix: types definition --- ast/postgresql.ts | 10 ++++++++-- pegjs/postgresql.pegjs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ast/postgresql.ts b/ast/postgresql.ts index 4a3c1012..729d9892 100644 --- a/ast/postgresql.ts +++ b/ast/postgresql.ts @@ -1145,6 +1145,10 @@ export type column_ref_array_index = column_ref; export type primary = cast_expr | or_and_where_expr | var_decl | { type: 'origin'; value: string; }; +export type unary_expr_or_primary = primary | unary_expr; + +export type unary_operator = "!" | "-" | "+" | "~"; + export type string_constants_escape = { type: 'origin'; value: string; }; @@ -1246,7 +1250,7 @@ type KW_SUM_MAX_MIN_AVG = never; export type aggr_fun_count = { type: 'aggr_func'; name: 'COUNT' | 'GROUP_CONCAT'; args:count_arg; over: over_partition } | { type: 'aggr_func'; name: 'PERCENTILE_CONT' | 'PERCENTILE_DISC'; args: literal_numeric | literal_array; within_group_orderby: order_by_clause; over?: over_partition } | { type: 'aggr_func'; name: 'MODE'; args: literal_numeric | literal_array; within_group_orderby: order_by_clause; over?: over_partition }; -export type concat_separator = { keyword: string | null; value: literal_string; }; +export type concat_separator = { symbol: ','; delimiter: literal_string; }; @@ -1258,7 +1262,7 @@ export type distinct_args = { distinct: 'DISTINCT'; expr: expr; orderby?: order_ export type count_arg = { expr: star_expr } | distinct_args; -export type aggr_array_agg = { type: 'aggr_func'; args:count_arg; name: 'ARRAY_AGG'; orderby?: order_by_clause }; +export type aggr_array_agg = { type: 'aggr_func'; args:count_arg; name: 'ARRAY_AGG' | 'STRING_AGG'; }; @@ -1503,6 +1507,8 @@ type KW_ARRAY = never; type KW_ARRAY_AGG = never; +type KW_STRING_AGG = never; + type KW_COUNT = never; type KW_GROUP_CONCAT = never; diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 67ef56a0..2f45cbce 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -4121,7 +4121,7 @@ primary unary_expr_or_primary = primary / op:(unary_operator) tail:(__ unary_expr_or_primary) { - // if (op === '!') op = 'NOT' + // => unary_expr return createUnaryExpr(op, tail[1]) }