Skip to content
Permalink
Browse files

[BUGFIX] [Oracle] Make QgsOracleFeatureIterator() robust to reference…

…s to non existing fields in filter expression and order by
  • Loading branch information
rouault committed Jan 20, 2020
1 parent 44c37be commit c586029a5bd4170e5d507368effddd2dbfd2ec1b
Showing with 7 additions and 8 deletions.
  1. +7 −8 src/providers/oracle/qgsoraclefeatureiterator.cpp
@@ -70,23 +70,22 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour
// ensure that all attributes required for expression filter are being fetched
if ( mRequest.filterType() == QgsFeatureRequest::FilterExpression )
{
const auto constReferencedColumns = mRequest.filterExpression()->referencedColumns();
for ( const QString &field : constReferencedColumns )
const QSet<int> attributeIndexes = mRequest.filterExpression()->referencedAttributeIndexes( mSource->mFields );
for ( int attrIdx : attributeIndexes )
{
int attrIdx = mSource->mFields.lookupField( field );
if ( !mAttributeList.contains( attrIdx ) )
mAttributeList << attrIdx;
}
}

// ensure that all attributes required for order by are fetched
const QSet< QString > orderByAttributes = mRequest.orderBy().usedAttributes();
for ( const QString &attr : orderByAttributes )
const auto orderByAttributes = mRequest.orderBy().usedAttributeIndices( mSource->mFields );
for ( int attrIdx : orderByAttributes )
{
int attrIndex = mSource->mFields.lookupField( attr );
if ( !mAttributeList.contains( attrIndex ) )
mAttributeList << attrIndex;
if ( !mAttributeList.contains( attrIdx ) )
mAttributeList << attrIdx;
}

}
else
mAttributeList = mSource->mFields.allAttributesList();

0 comments on commit c586029

Please sign in to comment.
You can’t perform that action at this time.