mirror of https://github.com/apache/lucene.git
SOLR-8652: Check if second to last token is limit to test for limit clause
This commit is contained in:
parent
ba20faa955
commit
75a81795b8
|
@ -26,6 +26,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -59,7 +60,7 @@ class StatementImpl implements Statement {
|
||||||
this.currentResultSet = null;
|
this.currentResultSet = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(maxRows > 0 && !(sql.toLowerCase()).contains("limit")) {
|
if(maxRows > 0 && !containsLimit(sql)) {
|
||||||
sql = sql + " limit "+Integer.toString(maxRows);
|
sql = sql + " limit "+Integer.toString(maxRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,4 +357,10 @@ class StatementImpl implements Statement {
|
||||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean containsLimit(String sql) {
|
||||||
|
String[] tokens = sql.split("\\s+");
|
||||||
|
String secondToLastToken = tokens[tokens.length-2];
|
||||||
|
return ("limit").equals(secondToLastToken);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue