17
17
#include " qgsogrprovider.h"
18
18
#include " qgsogrgeometrysimplifier.h"
19
19
#include " qgsogrexpressioncompiler.h"
20
+ #include " qgssqliteexpressioncompiler.h"
20
21
21
22
#include " qgsogrutils.h"
22
23
#include " qgsapplication.h"
@@ -100,13 +101,20 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
100
101
if ( request.filterType () == QgsFeatureRequest::FilterExpression
101
102
&& QSettings ().value ( " /qgis/compileExpressions" , true ).toBool () )
102
103
{
103
- QgsOgrExpressionCompiler compiler = QgsOgrExpressionCompiler ( source );
104
-
105
- QgsSqlExpressionCompiler::Result result = compiler.compile ( request.filterExpression () );
104
+ QgsSqlExpressionCompiler* compiler;
105
+ if ( source->mDriverName == " SQLite" || source->mDriverName == " GPKG" )
106
+ {
107
+ compiler = new QgsSQLiteExpressionCompiler ( source->mFields );
108
+ }
109
+ else
110
+ {
111
+ compiler = new QgsOgrExpressionCompiler ( source );
112
+ }
106
113
114
+ QgsSqlExpressionCompiler::Result result = compiler->compile ( request.filterExpression () );
107
115
if ( result == QgsSqlExpressionCompiler::Complete || result == QgsSqlExpressionCompiler::Partial )
108
116
{
109
- QString whereClause = compiler. result ();
117
+ QString whereClause = compiler-> result ();
110
118
if ( OGR_L_SetAttributeFilter ( ogrLayer, mSource ->mEncoding ->fromUnicode ( whereClause ).constData () ) == OGRERR_NONE )
111
119
{
112
120
// if only partial success when compiling expression, we need to double-check results using QGIS' expressions
@@ -118,6 +126,8 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
118
126
{
119
127
OGR_L_SetAttributeFilter ( ogrLayer, nullptr );
120
128
}
129
+
130
+ delete compiler;
121
131
}
122
132
else
123
133
{
0 commit comments