Skip to content

Commit

Permalink
for #701: fix bug for limit parse parameters index incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Apr 5, 2018
1 parent 6602ade commit 1aee4f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public void parse(final SelectStatement selectStatement) {
selectStatement.setLimit(getLimitWithOffset(valueIndex, valueBeginPosition, value, isParameterForValue, selectStatement));
return;
}
if (!isParameterForValue) {
if (isParameterForValue) {
selectStatement.increaseParametersIndex();
} else {
selectStatement.getSqlTokens().add(new RowCountToken(valueBeginPosition, value));
}
Limit limit = new Limit(DatabaseType.MySQL);
Expand All @@ -99,10 +101,14 @@ private Limit getLimitWithComma(final int index, final int valueBeginPosition, f
throw new SQLParsingException(lexerEngine);
}
lexerEngine.nextToken();
if (!isParameterForValue) {
if (isParameterForValue) {
selectStatement.increaseParametersIndex();
} else {
selectStatement.getSqlTokens().add(new OffsetToken(valueBeginPosition, value));
}
if (!isParameterForRowCount) {
if (isParameterForRowCount) {
selectStatement.increaseParametersIndex();
} else {
selectStatement.getSqlTokens().add(new RowCountToken(rowCountBeginPosition, rowCountValue));
}
Limit result = new Limit(DatabaseType.MySQL);
Expand All @@ -127,10 +133,14 @@ private Limit getLimitWithOffset(final int index, final int valueBeginPosition,
throw new SQLParsingException(lexerEngine);
}
lexerEngine.nextToken();
if (!isParameterForOffset) {
if (isParameterForOffset) {
selectStatement.increaseParametersIndex();
} else {
selectStatement.getSqlTokens().add(new OffsetToken(offsetBeginPosition, offsetValue));
}
if (!isParameterForValue) {
if (isParameterForValue) {
selectStatement.increaseParametersIndex();
} else {
selectStatement.getSqlTokens().add(new RowCountToken(valueBeginPosition, value));
}
Limit result = new Limit(DatabaseType.MySQL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public SelectStatement mergeSubQueryStatement() {
SelectStatement result = processLimitForSubQuery();
processItems(result);
processOrderByItems(result);
result.setParametersIndex(getParametersIndex());
return result;
}

Expand Down

0 comments on commit 1aee4f3

Please sign in to comment.