tconbeer / sqlfmt

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

for...else...endfor statement does not work #549

Closed yassun7010 closed 6 months ago

yassun7010 commented 6 months ago

Describe the bug for...else...endfor statements does not support.

I have verified that it works correctly in jinja sandbox.

To Reproduce The following code fails on sandbox.

{% for i in range(5) %}
    select 1
{% else %}
    select 2
{% endfor %}

Expected behavior


    select 1

    select 1

    select 1

    select 1

    select 1

Actual behavior The following error occur.

sqlfmt encountered an error: Closing jinja tag '{% endfor %}' found at pos 61 does not match last opened tag '{% else %}' found at pos 37.

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

sqlfmt, version 0.21.1
tconbeer commented 6 months ago

Thanks for the report. I didn't realize you could use for...else in Jinja