Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pegjs/postgresql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -5365,15 +5365,13 @@ cast_data_type
}

cast_double_colon
= s:(KW_DOUBLE_COLON __ cast_data_type)+ __ alias:alias_clause? {
= s:(KW_DOUBLE_COLON __ cast_data_type)+ {
/* => {
as?: alias_clause,
symbol: '::' | 'as',
target: cast_data_type[];
}
*/
return {
as: alias,
symbol: '::',
target: s.map(v => v[2]),
}
Expand Down
7 changes: 7 additions & 0 deletions test/postgres.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,13 @@ describe('Postgres', () => {
'ALTER TABLE "table_name" REPLICA IDENTITY FULL',
]
},
{
title: 'cast without parentheses and with alias',
sql: [
'SELECT "createdAt"::date AS created_at, "updatedAt"::date "updated_at", count(*) as "value"',
'SELECT "createdAt"::DATE AS "created_at", "updatedAt"::DATE AS "updated_at", COUNT(*) AS "value"'
]
},
]
function neatlyNestTestedSQL(sqlList){
sqlList.forEach(sqlInfo => {
Expand Down