Formatting issues with postgres: format(...), public.* + table_name.*
Describe the bug When formatting sql files for postgres I've noticed some bugs that cause failures.
- When using the postgres
format(...)function and dollar quoted strings, format specifiers are separated by a space. - When being explicit about using the public schema in postgres it get's separated by a space.
- When using
SELECT table_name.*syntax for all columns from a specific table it get's seperated by a space.
To Reproduce Format the following:
SELECT
-- 1
FORMAT($$%s %I %L$$, 'hello', 'i''m', 'a string') AS formatted_string,
-- 2
public.uuid_generate_v4() AS a_uuid,
-- 3
a_table.*
FROM (VALUES ('hello'), ('there')) AS a_table (a_column)
and the output will be:
SELECT -- 1
FORMAT($$ % s % I % L$$, 'hello', 'i''m', 'a string') AS formatted_string,
-- 2
PUBLIC .uuid_generate_v4() AS a_uuid,
-- 3
a_table. *
FROM (
VALUES ('hello'),
('there')
) AS a_table (a_column)
Expected behaviour
SELECT -- 1
FORMAT($$ %s %I %L$$, 'hello', 'i''m', 'a string') AS formatted_string,
-- 2
public.uuid_generate_v4() AS a_uuid,
-- 3
a_table.*
FROM (
VALUES ('hello'),
('there')
) AS a_table (a_column)
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- SQLTools Version: v0.28.0
- VS Code Version: 1.81.1
- OS: Mac
- Driver:
- [x] PostgreSQL/Redshift
- [ ] MySQL/MariaDB
- [ ] MSSQL/Azure
- [ ] SQLite
- [ ] Other? Which...
- Database version: PostgreSQL v14
Am I correct in guessing that you have set the language property of the sqltools.format settings object to "pl/sql"? I can reproduce your example with that setting but not when that property isn't defined.
Yes correct!
Workaround is to disable formatting by setting "sqltools.formatLanguages": [],
Please make sure you restart VS Code after you do this.