Skip to content

Commit

Permalink
Support comments after SET keyword (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonadern authored Sep 11, 2024
1 parent 38fd08b commit d3688b2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/uroborosql-fmt/src/visitor/clause/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ impl Visitor {
let mut set_clause = Clause::from_node(cursor.node(), src);
cursor.goto_next_sibling();

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

ensure_kind(cursor, "set_clause_body", src)?;
cursor.goto_first_child();

Expand Down
10 changes: 10 additions & 0 deletions crates/uroborosql-fmt/testfiles/dst/update/update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ set
, tbl1.column3 = 100 -- カラム3
where
tbl1.column1 = 10
;
update
t t
set
-- after set keyword
-- another comment
c = c + 1
where
id = 1
;
11 changes: 10 additions & 1 deletion crates/uroborosql-fmt/testfiles/src/update/update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@ UPDATE TABLE1 TBL1 -- テーブル1
SET TBL1.COLUMN2 = 100 -- カラム2
, TBL1.COLUMN3 = 100 -- カラム3
WHERE TBL1.COLUMN1 = 10

;

update
T t
set -- after set keyword
-- another comment
c = c + 1
where
id = 1
;

0 comments on commit d3688b2

Please sign in to comment.