diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 7bfb3e8a..cc5eb821 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -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]), } diff --git a/test/postgres.spec.js b/test/postgres.spec.js index 000ef4c7..459d4f0f 100644 --- a/test/postgres.spec.js +++ b/test/postgres.spec.js @@ -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 => {