Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
yydeng626 committed Jan 29, 2024
1 parent b6277a1 commit 27e2749
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,8 @@ public ASTNode visitSelectClause(final SelectClauseContext ctx) {
result.setHaving((HavingSegment) visit(ctx.havingClause()));
}
if (null != ctx.orderByClause()) {
visitOrderBy(result, ctx.orderByClause());
result.setOrderBy(getOrderBySegment(ctx.orderByClause()));
result.setLimit(getLimitSegment(ctx.orderByClause()));
}
return result;
}
Expand Down Expand Up @@ -954,16 +955,10 @@ public ASTNode visitHavingClause(final HavingClauseContext ctx) {
return new HavingSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), expr);
}

private SQLServerSelectStatement visitOrderBy(final SQLServerSelectStatement selectStatement, final OrderByClauseContext ctx) {
selectStatement.setOrderBy(getOrderBySegment(ctx));
selectStatement.setLimit(getLimitSegment(ctx));
return selectStatement;
}

private LimitSegment getLimitSegment(final OrderByClauseContext ctx) {
LimitSegment result = null;
PaginationValueSegment offset = null;
PaginationValueSegment rowcount = null;
LimitSegment limitSegment = null;
if (null != ctx.OFFSET()) {
ASTNode astNode = visit(ctx.expr(0));
if (astNode instanceof LiteralExpressionSegment && ((LiteralExpressionSegment) astNode).getLiterals() instanceof Number) {
Expand All @@ -983,9 +978,9 @@ private LimitSegment getLimitSegment(final OrderByClauseContext ctx) {
}
}
if (null != offset) {
limitSegment = new LimitSegment(ctx.OFFSET().getSymbol().getStartIndex(), ctx.stop.getStopIndex(), offset, rowcount);
result = new LimitSegment(ctx.OFFSET().getSymbol().getStartIndex(), ctx.stop.getStopIndex(), offset, rowcount);
}
return limitSegment;
return result;
}

private OrderBySegment getOrderBySegment(final OrderByClauseContext ctx) {
Expand All @@ -996,8 +991,7 @@ private OrderBySegment getOrderBySegment(final OrderByClauseContext ctx) {
items.add((OrderByItemSegment) visit(each));
orderByStopIndex = each.stop.getStopIndex();
}
OrderBySegment orderBySegment = new OrderBySegment(orderByStartIndex, orderByStopIndex, items);
return orderBySegment;
return new OrderBySegment(orderByStartIndex, orderByStopIndex, items);
}

private boolean isDistinct(final SelectClauseContext ctx) {
Expand Down

0 comments on commit 27e2749

Please sign in to comment.