Skip to content

Commit 49c243c

Browse files
committed
Fixes #13747
1 parent 15f59ae commit 49c243c

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/providers/spatialite/qgsspatialitefeatureiterator.cpp

+21-6
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,46 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeature
3434
mHasPrimaryKey = !mSource->mPrimaryKey.isEmpty();
3535
mRowNumber = 0;
3636

37+
QStringList whereClauses;
3738
QString whereClause;
3839
if ( !request.filterRect().isNull() && !mSource->mGeometryColumn.isNull() )
3940
{
4041
// some kind of MBR spatial filtering is required
41-
whereClause += whereClauseRect();
42+
whereClause = whereClauseRect();
43+
if ( ! whereClause.isEmpty() )
44+
{
45+
whereClauses.append( whereClause );
46+
}
4247
}
4348

4449
if ( request.filterType() == QgsFeatureRequest::FilterFid )
4550
{
46-
whereClause += whereClauseFid();
51+
whereClause = whereClauseFid();
52+
if ( ! whereClause.isEmpty() )
53+
{
54+
whereClauses.append( whereClause );
55+
}
4756
}
4857
else if ( request.filterType() == QgsFeatureRequest::FilterFids )
4958
{
50-
whereClause += whereClauseFids();
59+
whereClause = whereClauseFids();
60+
if ( ! whereClause.isEmpty() )
61+
{
62+
whereClauses.append( whereClause );
63+
}
5164
}
5265

5366
if ( !mSource->mSubsetString.isEmpty() )
5467
{
55-
if ( !whereClause.isEmpty() )
68+
whereClause = "( " + mSource->mSubsetString + ')';
69+
if ( ! whereClause.isEmpty() )
5670
{
57-
whereClause += " AND ";
71+
whereClauses.append( whereClause );
5872
}
59-
whereClause += "( " + mSource->mSubsetString + ")";
6073
}
6174

75+
whereClause = whereClauses.join( " AND " );
76+
6277
// preparing the SQL statement
6378
if ( !prepareStatement( whereClause ) )
6479
{

0 commit comments

Comments
 (0)