Skip to content

Commit

Permalink
Support comments after join keyword (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonadern authored Sep 5, 2024
1 parent cb71681 commit 8535b10
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/uroborosql-fmt/src/visitor/clause/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ impl Visitor {
};
cursor.goto_next_sibling();

// キーワード直後のコメントを処理
self.consume_comment_in_clause(cursor, src, &mut join_clause)?;

// テーブル名だが補完は行わない
let table = self.visit_aliasable_expr(cursor, src, None)?;
let body = Body::from(Expr::Aligned(Box::new(table)));
Expand Down
11 changes: 11 additions & 0 deletions crates/uroborosql-fmt/testfiles/dst/select/join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,14 @@ inner join
t2 -- tbl
on
t1.num = t2.num -- cond
;
select
*
from
t1 -- after table
inner join
-- after keyword
-- another comment
t2 -- after table
on
t1.num = t2.num -- cond
11 changes: 10 additions & 1 deletion crates/uroborosql-fmt/testfiles/src/select/join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ select * from t1 -- table 1
cross join t2 -- table 2
;
select * from t1 inner join t2 -- tbl
on t1.num = t2.num -- cond
on t1.num = t2.num -- cond
;
select
*
from
t1 -- after table
inner join -- after keyword
-- another comment
t2 -- after table
on t1.num = t2.num -- cond

0 comments on commit 8535b10

Please sign in to comment.