Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting issues with postgres: format(...), public.* + table_name.* #1202

Open
1 of 5 tasks
bowdi opened this issue Aug 18, 2023 · 3 comments
Open
1 of 5 tasks

Formatting issues with postgres: format(...), public.* + table_name.* #1202

bowdi opened this issue Aug 18, 2023 · 3 comments

Comments

@bowdi
Copy link

bowdi commented Aug 18, 2023

Describe the bug
When formatting sql files for postgres I've noticed some bugs that cause failures.

  1. When using the postgres format(...) function and dollar quoted strings, format specifiers are separated by a space.
  2. When being explicit about using the public schema in postgres it get's separated by a space.
  3. 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:
    • PostgreSQL/Redshift
    • MySQL/MariaDB
    • MSSQL/Azure
    • SQLite
    • Other? Which...
  • Database version: PostgreSQL v14
@bowdi bowdi added the triage label Aug 18, 2023
@bowdi bowdi changed the title Formatting issues with postgres: format(...) + public.* Formatting issues with postgres: format(...), public.* + table_name.* Aug 23, 2023
@gjsjohnmurray
Copy link
Collaborator

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.

@bowdi
Copy link
Author

bowdi commented Sep 4, 2023

Yes correct!

@gjsjohnmurray
Copy link
Collaborator

Workaround is to disable formatting by setting "sqltools.formatLanguages": [],

Please make sure you restart VS Code after you do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants