diff --git a/src/providers/postgres/qgspostgresfeatureiterator.cpp b/src/providers/postgres/qgspostgresfeatureiterator.cpp index 6904b1c8ff20..305647b8da11 100644 --- a/src/providers/postgres/qgspostgresfeatureiterator.cpp +++ b/src/providers/postgres/qgspostgresfeatureiterator.cpp @@ -289,14 +289,14 @@ QString QgsPostgresFeatureIterator::whereClauseRect() .arg( mSource->mRequestedSrid.isEmpty() ? mSource->mDetectedSrid : mSource->mRequestedSrid ); } + bool castToGeometry = mSource->mSpatialColType == sctGeography || + mSource->mSpatialColType == sctPcPatch; + QString whereClause = QString( "%1%2 && %3" ) .arg( QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ) ) - .arg( mSource->mSpatialColType == sctPcPatch ? "::geometry" : "" ) + .arg( castToGeometry ? "::geometry" : "" ) .arg( qBox ); - bool castToGeometry = mSource->mSpatialColType == sctGeography || - mSource->mSpatialColType == sctPcPatch; - if ( mRequest.flags() & QgsFeatureRequest::ExactIntersect ) { QString curveToLineFn; // in postgis < 1.5 the st_curvetoline function does not exist