You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After a finite number of iterations (ideally 1 馃檪), sqlfluff fix should eventually converge on an output that it is happy with.
Observed Behaviour
sqlfluff fix keeps adding whitespace before some for / endfor Jinja tags, and then removing it again upon a successive invocation (which makes it challenging to use as, e.g., a pre-commit hook).
Steps to Reproduce
$ echo'{% set elements = "foo" %}SELECT {% for elem in elements %} {{ elem }}, {% endfor %} {% for elem in elements %} {{ elem }}+ {% endfor %} 0' > test_0.sql
$ fornin$(seq 5);do cp test_$((n-1)).sql test_$n.sql ; sqlfluff fix --force test_$n.sql ;done(sqlfluff output omitted)
$ diff -u test_4.sql test_5.sql--- test_4.sql 2021-09-23 16:36:30.696291287 +0000+++ test_5.sql 2021-09-23 16:36:31.232985009 +0000@@ -3,10 +3,10 @@ SELECT {% for elem in elements %} {{ elem }},- {% endfor %}+{% endfor %}- {% for elem in elements %}+ {% for elem in elements %} {{ elem }} +- {% endfor %}+{% endfor %} 0
I have a PR which addresses #1425. This seems like a different issue. Most likely, there are two different lint rules with contradictory "opinions" about good linting.
Until this is fixed, a possible workaround (and helpful info for fixing!) would be to run the fixer in verbose mode (-vvvv) and see which rules are firing each time. I think you'll see an alternating pair of rules from one run to the next. If you disable one of these rules, you should get stable lint output.
I have a fix that makes L001 smarter -- it no longer removes "trailing whitespace" if there's template code following the whitespace. Does this fix the original issue, @CyberShadow?
Expected Behaviour
After a finite number of iterations (ideally 1 馃檪),
sqlfluff fix
should eventually converge on an output that it is happy with.Observed Behaviour
sqlfluff fix
keeps adding whitespace before somefor
/endfor
Jinja tags, and then removing it again upon a successive invocation (which makes it challenging to use as, e.g., a pre-commit hook).Steps to Reproduce
Dialect
None specified
Version
SQLFluff a50454c, Python 3.9.7
Configuration
None
The text was updated successfully, but these errors were encountered: