1717#include " qgsogrprovider.h"
1818#include " qgsogrgeometrysimplifier.h"
1919#include " qgsogrexpressioncompiler.h"
20+ #include " qgssqliteexpressioncompiler.h"
2021
2122#include " qgsogrutils.h"
2223#include " qgsapplication.h"
@@ -100,13 +101,20 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
100101 if ( request.filterType () == QgsFeatureRequest::FilterExpression
101102 && QSettings ().value ( " /qgis/compileExpressions" , true ).toBool () )
102103 {
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+ }
106113
114+ QgsSqlExpressionCompiler::Result result = compiler->compile ( request.filterExpression () );
107115 if ( result == QgsSqlExpressionCompiler::Complete || result == QgsSqlExpressionCompiler::Partial )
108116 {
109- QString whereClause = compiler. result ();
117+ QString whereClause = compiler-> result ();
110118 if ( OGR_L_SetAttributeFilter ( ogrLayer, mSource ->mEncoding ->fromUnicode ( whereClause ).constData () ) == OGRERR_NONE )
111119 {
112120 // 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
118126 {
119127 OGR_L_SetAttributeFilter ( ogrLayer, nullptr );
120128 }
129+
130+ delete compiler;
121131 }
122132 else
123133 {
0 commit comments