HHH-11650 - Parenthesis are interpreted in WHERE conditions when using paging and SQL Server

This commit is contained in:
Andrea Boriero 2017-04-20 13:14:37 +02:00 committed by Chris Cranford
parent 17fd76ad21
commit f9231bed0d
1 changed files with 6 additions and 2 deletions

View File

@ -387,15 +387,19 @@ public class SQLServer2005LimitHandler extends AbstractLimitHandler {
int depth = 0;
int start = -1;
boolean insideAStringValue = false;
for ( int i = 0; i < sql.length(); ++i ) {
final char ch = sql.charAt( i );
if ( ch == '(' ) {
if ( ch == '\'' ) {
insideAStringValue = !insideAStringValue;
}
else if ( ch == '(' && !insideAStringValue ) {
depth++;
if ( depth == 1 ) {
start = i;
}
}
else if ( ch == ')' ) {
else if ( ch == ')' && !insideAStringValue ) {
if ( depth > 0 ) {
if ( depth == 1 ) {
ignoreRangeList.add( new IgnoreRange( start, i ) );