Skip to content

Commit

Permalink
get the cache field id according to a lookupField() of the fields and…
Browse files Browse the repository at this point in the history
… the field name

since then would be aliases and upper-/lower case written fieldnames be accepted in
extensions and avoid a crash in getSpatialiteFieldNameFromUserVisibleName
  • Loading branch information
signedav committed Dec 6, 2019
1 parent d969e41 commit ea91966
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp
Expand Up @@ -353,7 +353,7 @@ QgsFeatureRequest QgsBackgroundCachedFeatureIterator::buildRequestCache( int gen
// 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 )
for ( const auto &columnName : setColumns )
{
int idx = fields.indexOf( columnName );
if ( idx >= 0 && fields[idx].type() == QVariant::DateTime )
Expand Down Expand Up @@ -410,12 +410,16 @@ QgsFeatureRequest QgsBackgroundCachedFeatureIterator::buildRequestCache( int gen
const auto referencedColumns = mRequest.filterExpression()->referencedColumns();
for ( const QString &field : referencedColumns )
{
int idx = dataProviderFields.indexFromName( mShared->getSpatialiteFieldNameFromUserVisibleName( field ) );
if ( idx >= 0 && !cacheSubSet.contains( idx ) )
cacheSubSet.append( idx );
idx = fields.indexFromName( field );
if ( idx >= 0 && !mSubSetAttributes.contains( idx ) )
mSubSetAttributes.append( idx );
int wfsFieldIdx = fields.lookupField( field );
if ( wfsFieldIdx != -1 )
{
int cacheFieldIdx = dataProviderFields.indexFromName( mShared->getSpatialiteFieldNameFromUserVisibleName( fields.at( wfsFieldIdx ).name() ) );
if ( cacheFieldIdx >= 0 && !cacheSubSet.contains( cacheFieldIdx ) )
cacheSubSet.append( cacheFieldIdx );

if ( wfsFieldIdx >= 0 && !mSubSetAttributes.contains( wfsFieldIdx ) )
mSubSetAttributes.append( wfsFieldIdx );
}
}
}

Expand Down

0 comments on commit ea91966

Please sign in to comment.