Skip to content

Commit

Permalink
Merge pull request #2050 from taozhi8833998/fix-quoted-data-type-pg
Browse files Browse the repository at this point in the history
fix: quoted column data type in pg
  • Loading branch information
taozhi8833998 authored Aug 3, 2024
2 parents 94393f6 + 99cd4ae commit 650501f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pegjs/postgresql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ create_column_definition_list

create_column_definition
= c:column_ref __
d:data_type __
d:(data_type / double_quoted_ident) __
cdo:column_definition_opt_list? {
/*
=> {
Expand All @@ -1335,6 +1335,7 @@ create_column_definition
}
*/
columnList.add(`create::${c.table}::${c.column.expr.value}`)
if (d.type === 'double_quote_string') d = { dataType: `"${d.value}"` }
return {
column: c,
definition: d,
Expand Down
7 changes: 7 additions & 0 deletions test/postgres.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,13 @@ describe('Postgres', () => {
`CREATE TABLE "public"."tnotok" ("id" SERIAL CONSTRAINT users_PK PRIMARY KEY, description TEXT NOT NULL DEFAULT ''::TEXT)`,
]
},
{
title: 'create table with quoted data type',
sql: [
'CREATE TABLE "User" ("gender" "Gender" NOT NULL);',
'CREATE TABLE "User" ("gender" "Gender" NOT NULL)',
]
},
]
function neatlyNestTestedSQL(sqlList){
sqlList.forEach(sqlInfo => {
Expand Down

0 comments on commit 650501f

Please sign in to comment.