HHH-11929 removed excessive toLowerCase() and substring() from SQLServer2012LimitHandler.hasOrderBy(). Also reversed the direction for scanning the sql string for "order by " to start at the end of the string
This commit is contained in:
parent
9394fadc9a
commit
6ad8302a3c
|
@ -110,8 +110,11 @@ public class SQLServer2012LimitHandler extends SQLServer2005LimitHandler {
|
||||||
|
|
||||||
private boolean hasOrderBy(String sql) {
|
private boolean hasOrderBy(String sql) {
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
for ( int i = 0; i < sql.length(); ++i ) {
|
|
||||||
char ch = sql.charAt( i );
|
String lowerCaseSQL = sql.toLowerCase();
|
||||||
|
|
||||||
|
for ( int i = lowerCaseSQL.length() - 1; i >= 0; --i ) {
|
||||||
|
char ch = lowerCaseSQL.charAt( i );
|
||||||
if ( ch == '(' ) {
|
if ( ch == '(' ) {
|
||||||
depth++;
|
depth++;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +122,7 @@ public class SQLServer2012LimitHandler extends SQLServer2005LimitHandler {
|
||||||
depth--;
|
depth--;
|
||||||
}
|
}
|
||||||
if ( depth == 0 ) {
|
if ( depth == 0 ) {
|
||||||
if ( sql.substring( i ).toLowerCase().startsWith( "order by " ) ) {
|
if ( lowerCaseSQL.startsWith( "order by ", i ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue