Skip to content

Commit

Permalink
docs: fix structure.else_null docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yk-kd authored and benfdking committed Nov 29, 2024
1 parent fb6adeb commit 602404d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
23 changes: 14 additions & 9 deletions crates/lib/src/rules/structure/st01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,27 @@ impl Rule for RuleST01 {
r#"
**Anti-pattern**
In this example, the reference `vee` has not been declared.
```sql
SELECT
vee.a
FROM foo
select
case
when name like '%cat%' then 'meow'
when name like '%dog%' then 'woof'
else null
end
from x
```
**Best practice**
Remove the reference.
Omit `else null`
```sql
SELECT
a
FROM foo
select
case
when name like '%cat%' then 'meow'
when name like '%dog%' then 'woof'
end
from x
```
"#
}
Expand Down
23 changes: 14 additions & 9 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2030,22 +2030,27 @@ Do not specify 'else null' in a case when statement (redundant).
**Anti-pattern**
In this example, the reference `vee` has not been declared.
```sql
SELECT
vee.a
FROM foo
select
case
when name like '%cat%' then 'meow'
when name like '%dog%' then 'woof'
else null
end
from x
```
**Best practice**
Remove the reference.
Omit `else null`
```sql
SELECT
a
FROM foo
select
case
when name like '%cat%' then 'meow'
when name like '%dog%' then 'woof'
end
from x
```
Expand Down

0 comments on commit 602404d

Please sign in to comment.