Skip to content

Commit

Permalink
HHH-14649 Oracle limit handler create wrong sql query when multiple s…
Browse files Browse the repository at this point in the history
…paces are present in the query

(cherry picked from commit 8002b18)
  • Loading branch information
dreab8 committed Apr 8, 2022
1 parent d13ed4b commit a31617f
Showing 1 changed file with 1 addition and 6 deletions.
Expand Up @@ -52,6 +52,7 @@ public String processSql(String sql, QueryParameters queryParameters) {
if ( !hasMaxRows ) {
return sql;
}
sql = sql.trim();

final LockOptions lockOptions = queryParameters.getLockOptions();
if ( lockOptions != null ) {
Expand Down Expand Up @@ -83,7 +84,6 @@ private String processSqlOffsetFetch(String sql, boolean hasFirstRow) {
bindLimitParametersInReverseOrder = false;
useMaxForLimit = false;

sql = normalizeStatement( sql );
final int offsetFetchLength;
final String offsetFetchString;
if ( hasFirstRow ) {
Expand All @@ -100,7 +100,6 @@ private String processSqlOffsetFetch(String sql, boolean hasFirstRow) {
private String processSql(String sql, int forUpdateIndex, boolean hasFirstRow) {
bindLimitParametersInReverseOrder = true;
useMaxForLimit = true;
sql = normalizeStatement( sql );

String forUpdateClause = null;
boolean isForUpdate = false;
Expand Down Expand Up @@ -142,10 +141,6 @@ private String processSql(String sql, int forUpdateIndex, boolean hasFirstRow) {
return pagingSelect.toString();
}

private String normalizeStatement(String sql) {
return sql.trim().replaceAll( "\\s+", " " );
}

private int getForUpdateIndex(String sql) {
final int forUpdateLastIndex = sql.toLowerCase( Locale.ROOT ).lastIndexOf( "for update" );
// We need to recognize cases like : select a from t where b = 'for update';
Expand Down

0 comments on commit a31617f

Please sign in to comment.