chore: add SQLFluff to pre-commit hooks#1774
Conversation
|
the added CI-step is failing though. This needs to be fixed for mergability ^^ |
|
@IvanPiatnishin You may want to run commands to fix the formatting errors. sqlfluff fix --dialect postgres demo/db/initdb/01.sql
sqlfluff fix --dialect postgres demo/db/initdb/03.sql
sqlfluff fix --dialect postgres martin/src/pg/scripts/query_available_function.sql |
|
There are a few things where you will need to look into the formatting. CI is still failing. |
|
Or just run this to fix all sqlfluff fix --dialect postgres |
|
Note that ideally this should not just verify the style, but just like cargo fmt it should push changes to the pr |
|
Note that this PR will not auto-run workflows because @IvanPiatnishin is a new github contributor. A workaround for this may be to create a PR in their own fork -- https://github.com/IvanPiatnishin/martin/compare/IvanPiatnishin:main...IvanPiatnishin:setup-sqlfluff-formatting?expand=1 |
|
On a more substantive notes - sqlfluff currently catches these two lints: Both are actually OK for us because that's the whole idea of those tests - to see if our code will work correctly when the user does something weird. So we should disable these specific lints in the config somewhere |
|
I changed a few things about the setup in be89425
I think I would like them to be ignored instead:
|
nyurik
left a comment
There was a problem hiding this comment.
looks good! It seems we might need to remove PG 11 support as it is no longer installing? (it should probably be a separate PR to keep things separate)
|
Is it possible to ignore certain rules just for a single file, or maybe even for a specific line in a file? We could use something like that for keywords and special character tests. |
|
Seems sqlfluff support In-File Configuration Directives, we can do that
And certain line could be configured by this -- Ignore all errors
SeLeCt 1 from tBl ; -- noqa
-- Ignore rule CP02 & rule CP03
SeLeCt 1 from tBl ; -- noqa: CP02,CP03
-- Ignore all parsing errors
SeLeCt from tBl ; -- noqa: PRS
|
Yes, see for example this file. We already do so: |
This adds SQLFluff with the PostgreSQL dialect to enforce SQL formatting rules via pre-commit.