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

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

Closed
yassun7010 opened this issue Jan 20, 2024 · 1 comment · Fixed by #551
Closed

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

yassun7010 opened this issue Jan 20, 2024 · 1 comment · Fixed by #551
Labels
bug Something isn't working

Comments

@yassun7010
Copy link

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
Copy link
Owner

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

@tconbeer tconbeer added the bug Something isn't working label Jan 22, 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants