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 authored and nyalldawson committed Jan 20, 2020
1 parent bf7dffe commit 58df76a9eff8c337242dcd4040505e57baa1c977
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 58df76a

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