Skip to content

Commit 05bb927

Browse files
committed
fix: reserved keyword as column name in postgresql
1 parent 11bd1bc commit 05bb927

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pegjs/postgresql.pegjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,7 +3256,7 @@ column_list_item
32563256
tail: tail && tail[0] && { operator: tail[0][1], expr: tail[0][3] },
32573257
}
32583258
}
3259-
/ tbl:ident_type __ DOT pro:(ident_type __ DOT)? __ STAR {
3259+
/ tbl:ident_type __ DOT pro:(ident_without_kw_type __ DOT)? __ STAR {
32603260
// => { expr: column_ref; as: null; }
32613261
const mid = pro && pro[0]
32623262
let schema
@@ -4409,7 +4409,7 @@ column_ref
44094409
column: '*'
44104410
}
44114411
}
4412-
/ schema:ident tbl:(__ DOT __ ident) col:(__ DOT __ column_type) {
4412+
/ schema:ident tbl:(__ DOT __ ident) col:(__ DOT __ column_without_kw_type) {
44134413
/* => {
44144414
type: 'column_ref';
44154415
schema: string;
@@ -4424,7 +4424,7 @@ column_ref
44244424
column: { expr: col[3] }
44254425
};
44264426
}
4427-
/ tbl:ident __ DOT __ col:column_type {
4427+
/ tbl:ident __ DOT __ col:column_without_kw_type {
44284428
/* => {
44294429
type: 'column_ref';
44304430
table: ident;

test/postgres.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,13 @@ describe('Postgres', () => {
19361936
'CREATE TABLE "User" ("id" SERIAL NOT NULL, CONSTRAINT "User_pkey" PRIMARY KEY ("id"))'
19371937
]
19381938
},
1939+
{
1940+
title: 'reserved keyword as column name',
1941+
sql: [
1942+
'select meeting.end from meeting',
1943+
'SELECT "meeting".end FROM "meeting"'
1944+
]
1945+
},
19391946
]
19401947
neatlyNestTestedSQL(SQL_LIST)
19411948
})

0 commit comments

Comments
 (0)