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

Postgres: "insert into ... values ..." indentation problem #5855

Open
2 of 3 tasks
nim8562 opened this issue May 6, 2024 · 0 comments
Open
2 of 3 tasks

Postgres: "insert into ... values ..." indentation problem #5855

nim8562 opened this issue May 6, 2024 · 0 comments
Labels
bug Something isn't working postgres Issues relating to the Postgres dialect

Comments

@nim8562
Copy link

nim8562 commented May 6, 2024

Search before asking

  • I searched the issues and found no similar issues.

What Happened

When I run sqlfluff-fix I get LT02-error and have my sql code changed from this. I use it via pre-commit hooks

INSERT INTO table (col1, col2, col3, col4)
    VALUES 
        (1, 2, 3, 4)
        (5, 6, 7, 8)

to this

INSERT INTO table (col1, col2, col3, col4)
VALUES 
(1, 2, 3, 4)
(5, 6, 7, 8)

Expected Behaviour

In documentation there is indentation for VALUES https://www.postgresql.org/docs/9.6/sql-insert.html
I expected sqlfluff linter and fix not to fail on it or give opportunity to manage settings.

INSERT INTO table (col1, col2, col3, col4)
    VALUES 
    (1, 2, 3, 4)
    (5, 6, 7, 8)

or

INSERT INTO table (col1, col2, col3, col4)
    VALUES 
        (1, 2, 3, 4)
        (5, 6, 7, 8)

Observed Behaviour

L: 13 | P: 1 | LT02 | Line should not be indented. [layout.indent]

How to reproduce

Run sqlfluff lint or sqlfluff fix against this file

INSERT INTO table (col1, col2, col3, col4)
    VALUES 
        (1, 2, 3, 4)
        (5, 6, 7, 8)

Dialect

postgres

Version

sqlfluff, version 3.0.5

Configuration

[tool.sqlfluff.core]
dialect = "postgres"
exclude_rules = "L034"
ignore = "templating"
sql_file_exts = ".sql"
max_line_length = 120

[tool.sqlfluff.indentation]
indented_joins = false
indented_using_on = true

[tool.sqlfluff.rules."layout.long_lines"]
ignore_comment_clauses = true
ignore_comment_lines = true

[tool.sqlfluff.rules."convention.count_rows"]
prefer_count_1 = true

[tool.sqlfluff.rules."capitalisation.functions"]
capitalisation_policy = "upper"

[tool.sqlfluff.rules."capitalisation.keywords"]
capitalisation_policy = "upper"

[tool.sqlfluff.rules."capitalisation.literals"]
capitalisation_policy = "upper"

[tool.sqlfluff.layout.type.column_constraint_segment]
spacing_before = 'align'
align_within = 'create_table_statement'

[tool.sqlfluff.layout.type.data_type]
spacing_before = 'align'
align_within = 'create_table_statement'

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

@nim8562 nim8562 added the bug Something isn't working label May 6, 2024
@github-actions github-actions bot added the postgres Issues relating to the Postgres dialect label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working postgres Issues relating to the Postgres dialect
Projects
None yet
Development

No branches or pull requests

1 participant