diff --git a/ast/postgresql.ts b/ast/postgresql.ts index 6dfe0e7a..6f44172c 100644 --- a/ast/postgresql.ts +++ b/ast/postgresql.ts @@ -845,12 +845,36 @@ export type join_op = 'LEFT JOIN' | 'RIGHT JOIN' | 'FULL JOIN' | 'CROSS JOIN' | export type table_name = { db?: ident; schema?: ident, table: ident | '*'; }; -export type binary_expr = { - type: 'binary_expr'; - operator: string; - left: string; - right: string; - } +export type BINARY_OPERATORS = + | LOGIC_OPERATOR + | "OR" + | "AND" + | multiplicative_operator + | additive_operator + | arithmetic_comparison_operator + | "IN" + | "NOT IN" + | "BETWEEN" + | "NOT BETWEEN" + | "IS" + | "IS NOT" + | "LIKE" + | "@>" + | "<@" + | OPERATOR_CONCATENATION + | DOUBLE_WELL_ARROW + | WELL_ARROW + | "?" + | "?|" + | "?&" + | "#-"; + + export type binary_expr = { + type: "binary_expr"; + operator: BINARY_OPERATORS; + left: expr; + right: expr; + }; export type or_and_expr = binary_expr; diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 249ce1f1..a637ae8b 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -3188,12 +3188,36 @@ table_name or_and_expr = head:expr tail:(__ (KW_AND / KW_OR) __ expr)* { /* + export type BINARY_OPERATORS = + | LOGIC_OPERATOR + | "OR" + | "AND" + | multiplicative_operator + | additive_operator + | arithmetic_comparison_operator + | "IN" + | "NOT IN" + | "BETWEEN" + | "NOT BETWEEN" + | "IS" + | "IS NOT" + | "LIKE" + | "@>" + | "<@" + | OPERATOR_CONCATENATION + | DOUBLE_WELL_ARROW + | WELL_ARROW + | "?" + | "?|" + | "?&" + | "#-"; + export type binary_expr = { - type: 'binary_expr'; - operator: string; - left: string; - right: string; - } + type: "binary_expr"; + operator: BINARY_OPERATORS; + left: expr; + right: expr; + }; => binary_expr */ const len = tail.length