Skip to content
Permalink
Browse files

[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
  • Loading branch information
rldhont authored and nyalldawson committed Feb 8, 2019
1 parent fc6695a commit 094620bcffd91b9a2a81f284e6d4e159d9b1b27b
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/providers/oracle/qgsoracleexpressioncompiler.cpp
@@ -58,11 +58,11 @@ QgsSqlExpressionCompiler::Result QgsOracleExpressionCompiler::compileNode( const
return Complete;

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

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

case QgsExpressionNodeBinaryOperator::boIntDiv:

0 comments on commit 094620b

Please sign in to comment.
You can’t perform that action at this time.