From 71385a2113e66c1148ab9feb1fa8b938a16a10fd Mon Sep 17 00:00:00 2001 From: taozhi8833998 Date: Mon, 9 Sep 2024 08:51:11 +0800 Subject: [PATCH] fix: create table as table defintion could be optional in pg --- pegjs/postgresql.pegjs | 2 +- test/postgres.spec.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 59440671..8a9cb084 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -832,7 +832,7 @@ create_table_stmt KW_TABLE __ ife:if_not_exists_stmt? __ t:table_ref_list __ - c:create_table_definition __ + c:create_table_definition? __ to:table_options? __ ir: (KW_IGNORE / KW_REPLACE)? __ as:KW_AS? __ diff --git a/test/postgres.spec.js b/test/postgres.spec.js index df275d10..1edbc339 100644 --- a/test/postgres.spec.js +++ b/test/postgres.spec.js @@ -1638,6 +1638,13 @@ describe('Postgres', () => { 'START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY, NOT DEFERRABLE' ] }, + { + title: 'create table as', + sql: [ + 'create table test as select 1', + 'CREATE TABLE "test" AS SELECT 1' + ] + }, ] function neatlyNestTestedSQL(sqlList){ sqlList.forEach(sqlInfo => {