@@ -34,31 +34,46 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeature
34
34
mHasPrimaryKey = !mSource ->mPrimaryKey .isEmpty ();
35
35
mRowNumber = 0 ;
36
36
37
+ QStringList whereClauses;
37
38
QString whereClause;
38
39
if ( !request.filterRect ().isNull () && !mSource ->mGeometryColumn .isNull () )
39
40
{
40
41
// some kind of MBR spatial filtering is required
41
- whereClause += whereClauseRect ();
42
+ whereClause = whereClauseRect ();
43
+ if ( ! whereClause.isEmpty () )
44
+ {
45
+ whereClauses.append ( whereClause );
46
+ }
42
47
}
43
48
44
49
if ( request.filterType () == QgsFeatureRequest::FilterFid )
45
50
{
46
- whereClause += whereClauseFid ();
51
+ whereClause = whereClauseFid ();
52
+ if ( ! whereClause.isEmpty () )
53
+ {
54
+ whereClauses.append ( whereClause );
55
+ }
47
56
}
48
57
else if ( request.filterType () == QgsFeatureRequest::FilterFids )
49
58
{
50
- whereClause += whereClauseFids ();
59
+ whereClause = whereClauseFids ();
60
+ if ( ! whereClause.isEmpty () )
61
+ {
62
+ whereClauses.append ( whereClause );
63
+ }
51
64
}
52
65
53
66
if ( !mSource ->mSubsetString .isEmpty () )
54
67
{
55
- if ( !whereClause.isEmpty () )
68
+ whereClause = " ( " + mSource ->mSubsetString + ' )' ;
69
+ if ( ! whereClause.isEmpty () )
56
70
{
57
- whereClause += " AND " ;
71
+ whereClauses. append ( whereClause ) ;
58
72
}
59
- whereClause += " ( " + mSource ->mSubsetString + " )" ;
60
73
}
61
74
75
+ whereClause = whereClauses.join ( " AND " );
76
+
62
77
// preparing the SQL statement
63
78
if ( !prepareStatement ( whereClause ) )
64
79
{
0 commit comments