Skip to content
Permalink
Browse files

[OGR] Ensure orig_ogc_fid is never set as ignored field

  • Loading branch information
manisandro committed Sep 25, 2017
1 parent 52bdbdf commit d02cca95363c273044a49e6c39b377a9794691de
@@ -152,6 +152,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
OGR_L_SetAttributeFilter( ogrLayer, nullptr );
}


//start with first feature
rewind();
}
@@ -1030,7 +1030,11 @@ void QgsOgrProviderUtils::setRelevantFields( OGRLayerH ogrLayer, int fieldCount,
if ( !fetchAttributes.contains( i ) )
{
// add to ignored fields
ignoredFields.append( OGR_Fld_GetNameRef( OGR_FD_GetFieldDefn( featDefn, firstAttrIsFid ? i - 1 : i ) ) );
const char *fieldName = OGR_Fld_GetNameRef( OGR_FD_GetFieldDefn( featDefn, firstAttrIsFid ? i - 1 : i ) );
if ( qstrcmp( fieldName, "orig_ogc_fid" ) != 0 )
{
ignoredFields.append( fieldName );
}
}
}

@@ -184,6 +184,18 @@ def testSubsetStringFids(self):
self.assertTrue(it.nextFeature(f))
self.assertTrue(f.id() == 5)

# Ensure that orig_ogc_fid is still retrieved even if attribute subset is passed
req = QgsFeatureRequest()
req.setSubsetOfAttributes([])
it = vl.getFeatures(req)
ids = []
while it.nextFeature(f):
ids.append(f.id())
self.assertTrue(len(ids) == 3)
self.assertTrue(3 in ids)
self.assertTrue(4 in ids)
self.assertTrue(5 in ids)

# Check that subset string is correctly set on reload
vl.reload()
self.assertTrue(vl.fields().at(vl.fields().count() - 1).name() == "orig_ogc_fid")

0 comments on commit d02cca9

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