Skip to content

Commit

Permalink
fix #218: add a space between using and bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
tconbeer committed Aug 2, 2022
1 parent fb3253f commit 5b2d861
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/sqlfmt/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def __init__(self) -> None:
r"(not\s+)?rlike",
r"some",
r"(not\s+)?similar\s+to",
r"using",
)
+ group(r"\W", r"$"),
action=partial(
Expand Down
6 changes: 3 additions & 3 deletions tests/data/unformatted/104_joins.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ left outer join four on
and three.four = four.three
and something_else
right join (
select id, five, six, seven, eight
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
Expand All @@ -26,7 +26,7 @@ left outer join
and something_else
right join
(
select id, five, six, seven, eight from my_table where some_filter is true
) as five using(five.id)
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
cross join {{ ref("bar_bar_bar") }} as bar
16 changes: 8 additions & 8 deletions tests/data/unformatted/115_select_star_except.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ select
recentagg_topactivities_array.topactivities,
) recentagg,
from recentagg_root
left join recentagg_topphases_array using(id)
left join recentagg_topsymptoms_array using(id)
left join recentagg_toppositivesymptoms_array using(id)
left join recentagg_topactivities_array using(id)
left join recentagg_topphases_array using (id)
left join recentagg_topsymptoms_array using (id)
left join recentagg_toppositivesymptoms_array using (id)
left join recentagg_topactivities_array using (id)
)))))__SQLFMT_OUTPUT__(((((
select
* except (field_a, field_b, field_c),
Expand Down Expand Up @@ -71,7 +71,7 @@ select
recentagg_topactivities_array.topactivities,
) recentagg,
from recentagg_root
left join recentagg_topphases_array using(id)
left join recentagg_topsymptoms_array using(id)
left join recentagg_toppositivesymptoms_array using(id)
left join recentagg_topactivities_array using(id)
left join recentagg_topphases_array using (id)
left join recentagg_topsymptoms_array using (id)
left join recentagg_toppositivesymptoms_array using (id)
left join recentagg_topactivities_array using (id)
4 changes: 1 addition & 3 deletions tests/data/unformatted/212_http_2019_cms_14_02.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ inner join
select _table_suffix as client, url
from `httparchive.technologies.2019_07_01_*`
where app = 'WordPress'
)
using
(client, url)
) using (client, url)
group by client, amp_plugin_mode
order by freq / total desc
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ left join
(
select one_field, two_fields, sum(something), my_very_long_field_name
from another_table
) as mysubquery using(id)
) as mysubquery using (id)
1 change: 1 addition & 0 deletions tests/unit_tests/test_node_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def test_identifier_whitespace(default_mode: Mode, source_string: str) -> None:
"(())\n",
"([])\n",
"()[] + foo()[offset(1)]\n",
"using (id)\n",
],
)
def test_bracket_whitespace(default_mode: Mode, source_string: str) -> None:
Expand Down

0 comments on commit 5b2d861

Please sign in to comment.