Skip to content

[Bug]: lt08 panics #1584

Open
Open
@amihajlovic

Description

@amihajlovic

What happened?

the issue can be reproduced by linting the following query:

with x as (
  select 1 as a
)
, b as ( select 2 as e)
select * 
from x,b;

output:

thread 'main' panicked at crates/lib/src/rules/layout/lt08.rs:191:35:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
== [tst.sql] FAIL
L:   1 | P:   1 | ???? | Unexpected exception. Could you open an issue at
                       | https://github.com/quarylabs/sqruff
L:   2 | P:   1 | LT02 | Expected indent of 4 spaces.
                       | [layout.indent]
L:   4 | P:   9 | LT01 | Unexpected whitespace before "select" keyword.
                       | [layout.spacing]
L:   5 | P:   9 | LT01 | Unnecessary trailing whitespace.
                       | [layout.spacing]
L:   6 | P:   8 | LT01 | Expected single whitespace between "," and "b".
                       | [layout.spacing]
The linter processed 1 file(s).
All Finished 📜 🎉

It seems the leading comma after the first cte is the problem. By moving the comma everything is as expected :

with x as (
  select 1 as a
),
 b as ( select 2 as e)
select * 
from x,b;
== [tst1.sql] FAIL
L:   2 | P:   1 | LT02 | Expected indent of 4 spaces.
                       | [layout.indent]
L:   4 | P:   1 | LT02 | Line should not be indented.
                       | [layout.indent]
L:   4 | P:   2 | LT08 | Blank line expected but not found after CTE closing
                       | bracket. [layout.cte_newline]
L:   4 | P:   8 | LT01 | Unexpected whitespace before "select" keyword.
                       | [layout.spacing]
L:   5 | P:   1 | LT08 | Blank line expected but not found after CTE closing
                       | bracket. [layout.cte_newline]
L:   5 | P:   9 | LT01 | Unnecessary trailing whitespace.
                       | [layout.spacing]
L:   6 | P:   8 | LT01 | Expected single whitespace between "," and "b".
                       | [layout.spacing]
The linter processed 1 file(s).
All Finished 📜 🎉

Version

sqruff 0.25.28

Checked in Playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions