Incorrect output when identifier with escaped quote used in select alias
zenazn opened this issue · comments
Carl Jackson commented
$ psql
psql (11.18)
Type "help" for help.
carl=# select 1 as "x""";
x"
----
1
(1 row)
But that query formats to:
$ pg_format --version
pg_format version 5.3
$ echo 'select 1 as "x"""' | pg_format
select
1 as "x" ""
Which predictably does not work:
carl=# select
1 as "x" "";
ERROR: zero-length delimited identifier at or near """"
LINE 2: 1 as "x" "";
^
I believe the correct way to format this query is
select
1 as "x"""
Gilles Darold commented
Commit 24c8203 fixes this issue.