mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-04 00:30:59 -05:00
[WFS/OAPIF provider] Do not forward filter expression to Spatialite cache if it depends on a DateTime field
Funded by Planet
This commit is contained in:
parent
2bba185c76
commit
bc8ee7ac32
@ -181,6 +181,9 @@ QgsBackgroundCachedFeatureIterator::QgsBackgroundCachedFeatureIterator(
|
||||
QgsFeatureRequest QgsBackgroundCachedFeatureIterator::buildRequestCache( int genCounter )
|
||||
{
|
||||
QgsFeatureRequest requestCache;
|
||||
|
||||
const auto &fields = mShared->fields();
|
||||
|
||||
auto cacheDataProvider = mShared->cacheDataProvider();
|
||||
if ( mRequest.filterType() == QgsFeatureRequest::FilterFid ||
|
||||
mRequest.filterType() == QgsFeatureRequest::FilterFids )
|
||||
@ -199,6 +202,21 @@ QgsFeatureRequest QgsBackgroundCachedFeatureIterator::buildRequestCache( int gen
|
||||
// We cannot filter on geometry because the spatialite geometry is just
|
||||
// a bounding box and not the actual geometry of the final feature
|
||||
!mRequest.filterExpression()->needsGeometry() )
|
||||
{
|
||||
// We cannot forward expressions using dateTime fields, because they
|
||||
// are stored as milliseconds since UTC epoch in the Spatialite DB.
|
||||
bool hasDateTimeFieldInExpr = false;
|
||||
const auto setColumns = mRequest.filterExpression()->referencedColumns();
|
||||
for ( const auto columnName : setColumns )
|
||||
{
|
||||
int idx = fields.indexOf( columnName );
|
||||
if ( idx >= 0 && fields[idx].type() == QVariant::DateTime )
|
||||
{
|
||||
hasDateTimeFieldInExpr = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !hasDateTimeFieldInExpr )
|
||||
{
|
||||
// Transfer and transform context
|
||||
requestCache.setFilterExpression( mRequest.filterExpression()->expression() );
|
||||
@ -210,6 +228,7 @@ QgsFeatureRequest QgsBackgroundCachedFeatureIterator::buildRequestCache( int gen
|
||||
}
|
||||
requestCache.setExpressionContext( ctx );
|
||||
}
|
||||
}
|
||||
if ( genCounter >= 0 )
|
||||
{
|
||||
requestCache.combineFilterExpression( QString( QgsBackgroundCachedFeatureIteratorConstants::FIELD_GEN_COUNTER + " <= %1" ).arg( genCounter ) );
|
||||
@ -224,7 +243,6 @@ QgsFeatureRequest QgsBackgroundCachedFeatureIterator::buildRequestCache( int gen
|
||||
mFetchGeometry = true;
|
||||
}
|
||||
|
||||
const auto &fields = mShared->fields();
|
||||
if ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes )
|
||||
{
|
||||
QgsFields dataProviderFields = cacheDataProvider->fields();
|
||||
|
Loading…
x
Reference in New Issue
Block a user