From fd0ab2b96756b61c68e4a812838333c5715562d6 Mon Sep 17 00:00:00 2001 From: taozhi8833998 Date: Thu, 5 Dec 2024 09:14:08 +0800 Subject: [PATCH] fix: column list include function name --- pegjs/postgresql.pegjs | 2 +- pegjs/redshift.pegjs | 2 +- pegjs/trino.pegjs | 2 +- test/postgres.spec.js | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 5a32ec88..6482c49e 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -4547,7 +4547,7 @@ column_ref column: { expr: col } }; } - / col:column_type { + / col:column_type !LPAREN { // => IGNORE columnList.add(`select::null::${col.value}`); return { diff --git a/pegjs/redshift.pegjs b/pegjs/redshift.pegjs index 3f3c8201..93cd9042 100644 --- a/pegjs/redshift.pegjs +++ b/pegjs/redshift.pegjs @@ -4025,7 +4025,7 @@ column_ref column: { expr: col } }; } - / col:column_type { + / col:column_type !LPAREN { // => IGNORE columnList.add(`select::null::${col.value}`); return { diff --git a/pegjs/trino.pegjs b/pegjs/trino.pegjs index fb92a00f..dd4ca41d 100644 --- a/pegjs/trino.pegjs +++ b/pegjs/trino.pegjs @@ -3442,7 +3442,7 @@ column_ref ...getLocationObject() }; } - / col:column_type { + / col:column_type !LPAREN { // => IGNORE columnList.add(`select::null::${col.value}`); return { diff --git a/test/postgres.spec.js b/test/postgres.spec.js index 1aa8a5d6..cc44296c 100644 --- a/test/postgres.spec.js +++ b/test/postgres.spec.js @@ -2116,6 +2116,9 @@ describe('Postgres', () => { } }) expect(parser.sqlify(ast.ast, opt)).to.be.equals('SELECT "col1" + "col2" FROM "t1"') + sql = 'SELECT SUM("source"."point" + "other_source"."other_point") FROM foo'; + ast = parser.parse(sql, opt) + expect(ast.columnList).to.be.eql(['select::source::point', 'select::other_source::other_point']) }) it('should support conflict be empty', () => {