tconbeer / sqlfmt

sqlfmt formats your dbt SQL files so you don't have to
https://sqlfmt.com
Apache License 2.0
390 stars 16 forks source link

Not automatically formatting when running from CLI ? #497

Closed wtfzambo closed 11 months ago

wtfzambo commented 11 months ago

Describe the bug I run sqlfmt myfile.sql or sqlfmt . from the CLI, and even if it can detect that a file needs formatting, it doesn't automatically apply it. Works ok when running in tandem with dbt-power-user and set as format when "format on save" is on.

If I run:

cat myfile.sql | sqlfmt -

the output is:

1 file failed formatting check.
0 files passed formatting check.
- failed formatting check.

However, --diff works fine and properly shows the rows it would change.

To Reproduce I'm in a pretty standard bread and butter dbt project, running in a devcontainer:

Expected behavior sqlfmt actually formats files in place when called from the CLI.

Actual behavior sqlfmt detects files that need formatting, but doesn't change them.

Additional context What is the output of sqlfmt --version?

image

tconbeer commented 11 months ago

The check=true config in your file prevents changes from being written to the file. Remove that config for the behavior you want.

wtfzambo commented 11 months ago

The check=true config in your file prevents changes from being written to the file. Remove that config for the behavior you want.

AH there you go, I knew I was being stupid somewhere. Thanks! Sorry for opening a stupid issue.