Skip to content
Permalink
Browse files

Fix feature fields does not include virtual or joined fields when

feature is requested using a QgsFeatureRequest with FilterFid
  • Loading branch information
nyalldawson committed May 10, 2016
1 parent e359a8e commit 3340d8ea70463385feaf72b1b4e4c6e7446b480e
Showing with 11 additions and 2 deletions.
  1. +2 −0 src/core/qgsvectorlayerfeatureiterator.cpp
  2. +9 −2 tests/src/python/test_qgsvectorlayer.py
@@ -806,6 +806,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 );

@@ -971,8 +971,15 @@ def test_ExpressionField(self):

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

self.assertEqual(next(layer.getFeatures())[idx], 5)
self.assertEqual(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')

0 comments on commit 3340d8e

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