Navigation Menu

Skip to content

Commit

Permalink
[BUGFIX] [Oracle] Make QgsOracleFeatureIterator() robust to reference…
Browse files Browse the repository at this point in the history
…s to non existing fields in filter expression and order by
  • Loading branch information
rouault authored and nyalldawson committed Jan 21, 2020
1 parent bf7dffe commit 58df76a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/providers/oracle/qgsoraclefeatureiterator.cpp
Expand Up @@ -70,23 +70,22 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour
// ensure that all attributes required for expression filter are being fetched // ensure that all attributes required for expression filter are being fetched
if ( mRequest.filterType() == QgsFeatureRequest::FilterExpression ) if ( mRequest.filterType() == QgsFeatureRequest::FilterExpression )
{ {
const auto constReferencedColumns = mRequest.filterExpression()->referencedColumns(); const QSet<int> attributeIndexes = mRequest.filterExpression()->referencedAttributeIndexes( mSource->mFields );
for ( const QString &field : constReferencedColumns ) for ( int attrIdx : attributeIndexes )
{ {
int attrIdx = mSource->mFields.lookupField( field );
if ( !mAttributeList.contains( attrIdx ) ) if ( !mAttributeList.contains( attrIdx ) )
mAttributeList << attrIdx; mAttributeList << attrIdx;
} }
} }


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

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

0 comments on commit 58df76a

Please sign in to comment.