Navigation Menu

Skip to content

Commit

Permalink
Fix feature fields does not include virtual or joined fields when
Browse files Browse the repository at this point in the history
feature is requested using a QgsFeatureRequest with FilterFid
  • Loading branch information
nyalldawson authored and rldhont committed May 11, 2016
1 parent c68d7f9 commit d5d7634
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/core/qgsvectorlayerfeatureiterator.cpp
Expand Up @@ -801,6 +801,8 @@ bool QgsVectorLayerFeatureIterator::nextFeatureFid( QgsFeature& f )
QgsFeatureIterator fi = mSource->mProviderFeatureSource->getFeatures( mProviderRequest );
if ( fi.nextFeature( f ) )
{
f.setFields( mSource->mFields );

if ( mSource->mHasEditBuffer )
updateChangedAttributes( f );

Expand Down
11 changes: 9 additions & 2 deletions tests/src/python/test_qgsvectorlayer.py
Expand Up @@ -967,8 +967,15 @@ def test_ExpressionField(self):

idx = layer.addExpressionField('5', QgsField('test', QVariant.LongLong))

self.assertEquals(layer.getFeatures().next()[idx], 5)
self.assertEquals(layer.pendingFields().count(), cnt + 1)
fet = next(layer.getFeatures())
self.assertEqual(fet[idx], 5)
# check fields
self.assertEqual(layer.fields().count(), cnt + 1)
self.assertEqual(fet.fields(), layer.fields())

# retrieve single feature and check fields
fet = next(layer.getFeatures(QgsFeatureRequest().setFilterFid(1)))
self.assertEqual(fet.fields(), layer.fields())

layer.updateExpressionField(idx, '9')

Expand Down

0 comments on commit d5d7634

Please sign in to comment.