Skip to content

Commit 62aefd7

Browse files
committedApr 17, 2018
[oracle] Compile some expression functions
Greatly speeds up case-insensitive value matches for oracle expression based feature requests (cherry-picked from 63e450a)
1 parent b7507fa commit 62aefd7

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed
 

‎src/providers/oracle/qgsoracleexpressioncompiler.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,28 @@ QString QgsOracleExpressionCompiler::quotedValue( const QVariant &value, bool &o
108108
return QgsOracleConn::quotedValue( value );
109109
}
110110
}
111+
112+
static const QMap<QString, QString> FUNCTION_NAMES_SQL_FUNCTIONS_MAP
113+
{
114+
{ "sqrt", "sqrt" },
115+
{ "abs", "abs" },
116+
{ "cos", "cos" },
117+
{ "sin", "sin" },
118+
{ "tan", "tan" },
119+
{ "acos", "acos" },
120+
{ "asin", "asin" },
121+
{ "atan", "atan" },
122+
{ "exp", "exp" },
123+
{ "ln", "ln" },
124+
{ "log", "log" },
125+
{ "round", "round" },
126+
{ "floor", "floor" },
127+
{ "ceil", "ceil" },
128+
{ "lower", "lower" },
129+
{ "upper", "upper" },
130+
};
131+
132+
QString QgsOracleExpressionCompiler::sqlFunctionFromFunctionName( const QString &fnName ) const
133+
{
134+
return FUNCTION_NAMES_SQL_FUNCTIONS_MAP.value( fnName, QString() );
135+
}

‎src/providers/oracle/qgsoracleexpressioncompiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class QgsOracleExpressionCompiler : public QgsSqlExpressionCompiler
3030
virtual Result compileNode( const QgsExpressionNode *node, QString &result ) override;
3131
virtual QString quotedIdentifier( const QString &identifier ) override;
3232
virtual QString quotedValue( const QVariant &value, bool &ok ) override;
33+
QString sqlFunctionFromFunctionName( const QString &fnName ) const override;
3334
};
3435

3536
#endif // QGSORACLEEXPRESSIONCOMPILER_H

‎tests/src/python/test_provider_oracle.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,34 +74,14 @@ def uncompiledFilters(self):
7474
'NULL or true',
7575
'NULL or NULL',
7676
'not null',
77-
'sqrt(pk) >= 2',
7877
'radians(cnt) < 2',
7978
'degrees(pk) <= 200',
80-
'abs(cnt) <= 200',
81-
'cos(pk) < 0',
82-
'sin(pk) < 0',
83-
'tan(pk) < 0',
84-
'acos(-1) < pk',
85-
'asin(1) < pk',
86-
'atan(3.14) < pk',
8779
'atan2(3.14, pk) < 1',
88-
'exp(pk) < 10',
89-
'ln(pk) <= 1',
90-
'log(3, pk) <= 1',
91-
'log10(pk) < 0.5',
92-
'round(3.14) <= pk',
93-
'round(0.314,1) * 10 = pk',
94-
'floor(3.14) <= pk',
95-
'ceil(3.14) <= pk',
9680
'pk < pi()',
97-
'round(cnt / 66.67) <= 2',
98-
'floor(cnt / 66.67) <= 2',
99-
'ceil(cnt / 66.67) <= 2',
81+
'log10(pk) < 0.5',
10082
'pk < pi() / 2',
10183
'pk = char(51)',
10284
'pk = coalesce(NULL,3,4)',
103-
'lower(name) = \'apple\'',
104-
'upper(name) = \'APPLE\'',
10585
'name = trim(\' Apple \')',
10686
'x($geometry) < -70',
10787
'y($geometry) > 70',

0 commit comments

Comments
 (0)
Please sign in to comment.