diff --git a/pegjs/noql.pegjs b/pegjs/noql.pegjs index 78d306af..1a52b551 100644 --- a/pegjs/noql.pegjs +++ b/pegjs/noql.pegjs @@ -489,6 +489,7 @@ create_aggregate_stmt ast: { type: 'create', keyword: 'aggregate', + replace: or && 'or replace', name: { schema: s.db, name: s.table }, args: { parentheses: true, diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 0ee67817..52ff95aa 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -379,15 +379,15 @@ create_db_stmt = a:KW_CREATE __ k:(KW_DATABASE / KW_SCHEMA) __ ife:if_not_exists_stmt? __ - t:ident_without_kw_type __ + t:proc_func_name __ c:create_db_definition? { /* export type create_db_stmt_t = { type: 'create', keyword: 'database' | 'schema', if_not_exists?: 'if not exists', - database?: { db: string, schema: string }; - schema?: { db: string, schema: string }; + database?: { db: ident_without_kw_type, schema: [ident_without_kw_type] }; + schema?: { db: ident_without_kw_type, schema: [ident_without_kw_type] }; create_definitions?: create_db_definition } => AstStatement @@ -400,7 +400,6 @@ create_db_stmt type: a[0].toLowerCase(), keyword, if_not_exists:ife, - replace: or && 'or replace', [keyword]: { db: t.schema, schema: t.name }, create_definitions: c, } diff --git a/test/postgres.spec.js b/test/postgres.spec.js index 2d117372..d62d89db 100644 --- a/test/postgres.spec.js +++ b/test/postgres.spec.js @@ -1905,6 +1905,13 @@ describe('Postgres', () => { `SELECT * FROM jsonb_to_recordset('[{"amount":23, "currency": "INR"}]'::JSONB) AS l_amount(amount DECIMAL, currency TEXT)` ] }, + { + title: 'create scheme', + sql: [ + 'CREATE SCHEMA public;', + 'CREATE SCHEMA public' + ] + }, ] neatlyNestTestedSQL(SQL_LIST) })