Skip to content

Commit 3084606

Browse files
committed
[oracle] Fix expression compilation of integer division
1 parent e93c97c commit 3084606

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/providers/oracle/qgsoracleexpressioncompiler.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ QgsSqlExpressionCompiler::Result QgsOracleExpressionCompiler::compileNode( const
3939
case QgsExpressionNodeBinaryOperator::boILike:
4040
case QgsExpressionNodeBinaryOperator::boNotILike:
4141
case QgsExpressionNodeBinaryOperator::boMod:
42+
case QgsExpressionNodeBinaryOperator::boIntDiv:
4243
{
4344
QString op1, op2;
4445

@@ -49,28 +50,34 @@ QgsSqlExpressionCompiler::Result QgsOracleExpressionCompiler::compileNode( const
4950
switch ( bin->op() )
5051
{
5152
case QgsExpressionNodeBinaryOperator::boPow:
52-
result = QString( "power(%1,%2)" ).arg( op1, op2 );
53+
result = QStringLiteral( "power(%1,%2)" ).arg( op1, op2 );
5354
return Complete;
5455

5556
case QgsExpressionNodeBinaryOperator::boRegexp:
56-
result = QString( "regexp_like(%1,%2)" ).arg( op1, op2 );
57+
result = QStringLiteral( "regexp_like(%1,%2)" ).arg( op1, op2 );
5758
return Complete;
5859

5960
case QgsExpressionNodeBinaryOperator::boILike:
60-
result = QString( "lower(%1) LIKE lower(%2)" ).arg( op1, op2 );
61+
result = QStringLiteral( "lower(%1) LIKE lower(%2)" ).arg( op1, op2 );
6162
return Complete;
6263

6364
case QgsExpressionNodeBinaryOperator::boNotILike:
64-
result = QString( "NOT lower(%1) LIKE lower(%2)" ).arg( op1, op2 );
65+
result = QStringLiteral( "NOT lower(%1) LIKE lower(%2)" ).arg( op1, op2 );
6566
return Complete;
6667

68+
case QgsExpressionNodeBinaryOperator::boIntDiv:
69+
result = QStringLiteral( "FLOOR(%1 / %2)" ).arg( op1, op2 );
70+
return Complete;
71+
72+
6773
case QgsExpressionNodeBinaryOperator::boMod :
68-
result = QString( "MOD(%1,%2)" ).arg( op1, op2 );
74+
result = QStringLiteral( "MOD(%1,%2)" ).arg( op1, op2 );
6975
return Complete;
7076

7177
default:
7278
break;
7379
}
80+
break; // no warnings
7481
}
7582

7683
default:
@@ -95,7 +102,7 @@ QString QgsOracleExpressionCompiler::quotedValue( const QVariant &value, bool &o
95102
{
96103
case QVariant::Bool:
97104
//no boolean literal support in Oracle, so fake it
98-
return value.toBool() ? "(1=1)" : "(1=0)";
105+
return value.toBool() ? QStringLiteral( "(1=1)" ) : QStringLiteral( "(1=0)" );
99106

100107
default:
101108
return QgsOracleConn::quotedValue( value );

0 commit comments

Comments
 (0)