Skip to content

Commit d42a7b2

Browse files
committedJan 16, 2019
[Bugfix][Oracle] Add ESCAPE when compiling LIKE
The oracle SQL documentation specifies that *there is no default escape character* and *the escape character, if specified, must be a character string of length 1*. In expression the underscore (_) and the percent sign (%) can be escaped with the backslash (\). So in the Oracle Expression Compiler if the ESCAPE clause is not specified, the pattern is not valid. To fix it, the Oracle Expression Compiler has to add the ESCAPE clause. https://docs.oracle.com/cd/B12037_01/server.101/b10759/conditions016.htm
1 parent 5ff59ce commit d42a7b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/providers/oracle/qgsoracleexpressioncompiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ QgsSqlExpressionCompiler::Result QgsOracleExpressionCompiler::compileNode( const
5858
return Complete;
5959

6060
case QgsExpressionNodeBinaryOperator::boILike:
61-
result = QStringLiteral( "lower(%1) LIKE lower(%2)" ).arg( op1, op2 );
61+
result = QStringLiteral( "lower(%1) LIKE lower(%2) ESCAPE '\\'" ).arg( op1, op2 );
6262
return Complete;
6363

6464
case QgsExpressionNodeBinaryOperator::boNotILike:
65-
result = QStringLiteral( "NOT lower(%1) LIKE lower(%2)" ).arg( op1, op2 );
65+
result = QStringLiteral( "NOT lower(%1) LIKE lower(%2) ESCAPE '\\'" ).arg( op1, op2 );
6666
return Complete;
6767

6868
case QgsExpressionNodeBinaryOperator::boIntDiv:

0 commit comments

Comments
 (0)
Please sign in to comment.