Skip to content

Commit

Permalink
fix: create scheme error in pg
Browse files Browse the repository at this point in the history
  • Loading branch information
taozhi8833998 committed Aug 24, 2024
1 parent ee57f22 commit c2f70bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions pegjs/noql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions pegjs/postgresql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -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<create_db_stmt_t>
Expand All @@ -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,
}
Expand Down
7 changes: 7 additions & 0 deletions test/postgres.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit c2f70bf

Please sign in to comment.