Skip to content

Commit

Permalink
Merge branch 'main' into markdown-parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
tconbeer authored Jul 9, 2024
2 parents b622a65 + adfb114 commit d764a03
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 236 deletions.
426 changes: 196 additions & 230 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "shandy-sqlfmt"
version = "0.21.3"
version = "0.21.4"
description = "sqlfmt formats your dbt SQL files so you don't have to."
readme = "README.md"
authors = ["Ted Conbeer <[email protected]>"]
Expand Down
5 changes: 4 additions & 1 deletion src/sqlfmt/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@
r"delete\s+from",
r"from",
r"((cross|positional|semi|anti)\s+)?join",
(r"((natural|asof)\s+)?" r"((inner|(left|right|full)(\s+outer)?)\s+)?join"),
(
r"((natural|asof)\s+)?"
r"((inner|(left|right|full)(\s+(outer|anti))?)\s+)?join"
),
# this is the USING following DELETE, not the join operator
# (see above)
r"using",
Expand Down
6 changes: 4 additions & 2 deletions tests/data/fast/unformatted/104_joins.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
select one.one, two.two,
three.three, four.four, five.five, six.six
three.three, four.four, five.five, six.six, seven.seven
from one
join two on one.two = two.one
inner join "my_database"."my_schema".three as three on one.three = three.one
Expand All @@ -12,9 +12,10 @@ right join (
from my_table where some_filter is true
) as five using(five.id)
natural full outer join six
left anti join seven on one.seven = seven.one
cross join {{ ref('bar_bar_bar') }} as bar
)))))__SQLFMT_OUTPUT__(((((
select one.one, two.two, three.three, four.four, five.five, six.six
select one.one, two.two, three.three, four.four, five.five, six.six, seven.seven
from one
join two on one.two = two.one
inner join "my_database"."my_schema".three as three on one.three = three.one
Expand All @@ -29,4 +30,5 @@ right join
select id, five, six, seven, eight, nine from my_table where some_filter is true
) as five using (five.id)
natural full outer join six
left anti join seven on one.seven = seven.one
cross join {{ ref("bar_bar_bar") }} as bar
6 changes: 4 additions & 2 deletions tests/data/unformatted/104_joins.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
select one.one, two.two,
three.three, four.four, five.five, six.six
three.three, four.four, five.five, six.six, seven.seven
from one
join two on one.two = two.one
inner join "my_database"."my_schema".three as three on one.three = three.one
Expand All @@ -12,9 +12,10 @@ right join (
from my_table where some_filter is true
) as five using(five.id)
natural full outer join six
left anti join seven on one.seven = seven.one
cross join {{ ref('bar_bar_bar') }} as bar
)))))__SQLFMT_OUTPUT__(((((
select one.one, two.two, three.three, four.four, five.five, six.six
select one.one, two.two, three.three, four.four, five.five, six.six, seven.seven
from one
join two on one.two = two.one
inner join "my_database"."my_schema".three as three on one.three = three.one
Expand All @@ -29,4 +30,5 @@ right join
select id, five, six, seven, eight, nine from my_table where some_filter is true
) as five using (five.id)
natural full outer join six
left anti join seven on one.seven = seven.one
cross join {{ ref("bar_bar_bar") }} as bar
2 changes: 2 additions & 0 deletions tests/unit_tests/test_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def get_rule(ruleset: List[Rule], rule_name: str) -> Rule:
(MAIN, "unterm_keyword", "asof left join"),
(MAIN, "unterm_keyword", "asof right\n outer\n join"),
(MAIN, "unterm_keyword", "semi join"),
(MAIN, "unterm_keyword", "left anti join"),
(MAIN, "unterm_keyword", "right anti join"),
(MAIN, "unterm_keyword", "anti join"),
(MAIN, "unterm_keyword", "join"),
(MAIN, "unterm_keyword", "values"),
Expand Down

0 comments on commit d764a03

Please sign in to comment.