Skip to content

Commit

Permalink
fix add comment & print comment
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed May 13, 2023
1 parent 634ad1a commit e8a37b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,16 @@ public List<String> computeSelecteListAlias() {
public boolean addWhere(SQLExpr where) {
return select.addWhere(where);
}

public void addBeforeComment(String comment) {
if (headHints == null && attributes == null && select.hints == null && select.getBeforeCommentsDirect() == null) {
SQLSelectQueryBlock queryBlock = select.getQueryBlock();
List<String> queryBlockBeforeComments = queryBlock.getBeforeCommentsDirect();
if (queryBlockBeforeComments != null) {
queryBlockBeforeComments.add(comment);
return;
}
}
super.addBeforeComment(comment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3022,6 +3022,10 @@ public boolean visit(SQLSelectStatement stmt) {
}
}

if (stmt.hasBeforeComment()) {
printlnComments(stmt.getBeforeCommentsDirect());
}

SQLSelect select = stmt.getSelect();
if (select != null) {
this.visit(select);
Expand Down

0 comments on commit e8a37b5

Please sign in to comment.