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

View File

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