diff --git a/ast/postgresql.ts b/ast/postgresql.ts index bee441c7..0d88e65d 100644 --- a/ast/postgresql.ts +++ b/ast/postgresql.ts @@ -1189,7 +1189,9 @@ export type trim_rem = expr_list; export type trim_func_clause = { type: 'function'; name: string; args: expr_list; }; -export type func_call = trim_func_clause | { type: 'function'; name: string; args: expr_list; suffix: literal_string; } | { type: 'function'; name: string; args: expr_list; over?: over_partition; } | extract_func | { type: 'function'; name: string; over?: on_update_current_timestamp; } | { type: 'function'; name: string; args: expr_list; }; +export type tablefunc_clause = { type: 'tablefunc'; name: crosstab; args: expr_list; as: func_call }; + +export type func_call = trim_func_clause | tablefunc_clause | { type: 'function'; name: string; args: expr_list; suffix: literal_string; } | { type: 'function'; name: string; args: expr_list; over?: over_partition; } | extract_func | { type: 'function'; name: string; over?: on_update_current_timestamp; } | { type: 'function'; name: string; args: expr_list; }; export type extract_filed = 'string'; diff --git a/package.json b/package.json index 05698e10..9a82ccc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-sql-parser", - "version": "4.12.0", + "version": "4.13.0", "description": "simple node sql parser", "main": "index.js", "types": "types.d.ts", diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index b9b532cb..9018877a 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -4313,6 +4313,7 @@ trim_func_clause tablefunc_clause = 'crosstab'i __ LPAREN __ s:literal_list __ RPAREN __ KW_AS __ 'final_result' LPAREN __ cds:column_data_type_list __ RPAREN { + // => { type: 'tablefunc'; name: crosstab; args: expr_list; as: func_call } return { type: 'tablefunc', name: 'crosstab', diff --git a/test/bigquery.spec.js b/test/bigquery.spec.js index a87fac3d..21faf4de 100644 --- a/test/bigquery.spec.js +++ b/test/bigquery.spec.js @@ -864,6 +864,9 @@ describe('BigQuery', () => { value: 'abc' } expect(arrayStructValueToSQL(expr)).to.equal(`['${expr.expr_list.value}']`) + expr.brackets = false + expr.parentheses = false + expect(arrayStructValueToSQL(expr)).to.equal(`'${expr.expr_list.value}'`) }) it('should return undefined and dataType', () => {