Skip to content

Commit

Permalink
fixed #292
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Jul 15, 2017
1 parent d725cfc commit f52301b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,17 @@ protected boolean isRowNumberCondition(final SelectStatement selectStatement, fi
*/
public void parseTop(final SelectStatement selectStatement) {
if (skipIfEqual(SQLServerKeyword.TOP)) {
skipIfEqual(Symbol.LEFT_PAREN);
int beginPosition = getLexer().getCurrentToken().getEndPosition();
if (!skipIfEqual(Symbol.LEFT_PAREN)) {
beginPosition = getLexer().getCurrentToken().getEndPosition() - getLexer().getCurrentToken().getLiterals().length();
}
SQLExpression sqlExpression = parseExpression();
skipIfEqual(Symbol.RIGHT_PAREN);
LimitValue rowCountValue;
if (sqlExpression instanceof SQLNumberExpression) {
int rowCount = ((SQLNumberExpression) sqlExpression).getNumber().intValue();
rowCountValue = new LimitValue(rowCount, -1);
selectStatement.getSqlTokens().add(
new RowCountToken(getLexer().getCurrentToken().getEndPosition() - String.valueOf(rowCount).length() - getLexer().getCurrentToken().getLiterals().length(), rowCount));
selectStatement.getSqlTokens().add(new RowCountToken(beginPosition, rowCount));
} else if (sqlExpression instanceof SQLPlaceholderExpression) {
rowCountValue = new LimitValue(-1, ((SQLPlaceholderExpression) sqlExpression).getIndex());
} else {
Expand Down

0 comments on commit f52301b

Please sign in to comment.