Skip to content
Permalink
Browse files

Merge pull request #8875 from rldhont/bugfix-oracle-compile-expressio…

…n-like-34

Add ESCAPE when compiling LIKE for oracle
  • Loading branch information
m-kuhn committed Feb 6, 2019
2 parents 57391d8 + d9bf6eb commit 92823d0f5943f055febbc8f52ffbd01f06dc7b92
@@ -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:
@@ -155,6 +155,8 @@ def runGetFeatureTests(self, source):
self.assert_query(source, '(name = \'Apple\') is not null', [1, 2, 3, 4])
self.assert_query(source, 'name LIKE \'Apple\'', [2])
self.assert_query(source, 'name LIKE \'aPple\'', [])
self.assert_query(source, 'name LIKE \'Ap_le\'', [2])
self.assert_query(source, 'name LIKE \'Ap\\_le\'', [])
self.assert_query(source, 'name ILIKE \'aPple\'', [2])
self.assert_query(source, 'name ILIKE \'%pp%\'', [2])
self.assert_query(source, 'cnt > 0', [1, 2, 3, 4])
@@ -203,6 +203,8 @@ def partiallyCompiledFilters(self):
'name = \'apple\'',
'name LIKE \'Apple\'',
'name LIKE \'aPple\'',
'name LIKE \'Ap_le\'',
'name LIKE \'Ap\\_le\'',
'"name"="name2"'])

def testRepack(self):

0 comments on commit 92823d0

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