From b3fc2015123565380d3e43318b4d64f1960df9ac Mon Sep 17 00:00:00 2001 From: taozhi8833998 Date: Thu, 13 Jun 2024 09:09:40 +0800 Subject: [PATCH 1/2] refactor: change or_replace to replace field --- pegjs/bigquery.pegjs | 2 +- src/create.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pegjs/bigquery.pegjs b/pegjs/bigquery.pegjs index 6f15348b..61a0a1c7 100644 --- a/pegjs/bigquery.pegjs +++ b/pegjs/bigquery.pegjs @@ -871,7 +871,7 @@ create_table_stmt temporary: tp && tp[0].toLowerCase(), if_not_exists:ife, table: [t], - or_replace: or && 'or replace', + replace: or && 'or replace', as: as && as[0].toLowerCase(), query_expr: qe && qe.ast, create_definitions: c, diff --git a/src/create.js b/src/create.js index 976d6c73..53e2d6ab 100644 --- a/src/create.js +++ b/src/create.js @@ -71,7 +71,7 @@ function createTableToSQL(stmt) { create_definitions: createDefinition, table_options: tableOptions, ignore_replace: ignoreReplace, - or_replace: orReplace, + replace: orReplace, partition_of: partitionOf, query_expr: queryExpr, } = stmt From 2fe22fd40a845e8b2620e844f0e3a84640e15f90 Mon Sep 17 00:00:00 2001 From: taozhi8833998 Date: Thu, 13 Jun 2024 09:15:59 +0800 Subject: [PATCH 2/2] refactor: fix npm run build error --- ast/postgresql.ts | 5 ++++- pegjs/postgresql.pegjs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ast/postgresql.ts b/ast/postgresql.ts index c9ba16f2..5b3a2bfe 100644 --- a/ast/postgresql.ts +++ b/ast/postgresql.ts @@ -31,6 +31,8 @@ export type union_stmt = AstStatement; export type if_not_exists_stmt = 'IF NOT EXISTS'; +export type if_exists = 'IF EXISTS'; + export type nameOrLiteral = literal_string | { type: 'same', value: string; }; export type create_extension_stmt = { @@ -326,12 +328,13 @@ export type drop_index_opt = (ALTER_ALGORITHM | ALTER_LOCK)[]; export interface drop_stmt_node { type: 'drop'; keyword: 'table'; + prefix?: string; name: table_ref_list; } export interface drop_index_stmt_node { type: 'drop'; - prefix?: 'CONCURRENTLY'; + prefix?: string; keyword: string; name: column_ref; options?: 'cascade' | 'restrict'; diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 98f332c0..10a157b0 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -330,7 +330,8 @@ if_not_exists_stmt if_exists = 'if'i __ 'exists'i { - return 'if exists' + // => 'IF EXISTS' + return 'IF EXISTS' } create_extension_stmt