mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-23 00:05:43 -04:00
[OGR] Ensure orig_ogc_fid is never set as ignored field
This commit is contained in:
parent
cf23d56aef
commit
15eaafdf0c
@ -176,6 +176,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
|
||||
OGR_L_SetAttributeFilter( ogrLayer, nullptr );
|
||||
}
|
||||
|
||||
|
||||
//start with first feature
|
||||
rewind();
|
||||
}
|
||||
|
@ -1022,7 +1022,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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,6 +254,18 @@ class TestPyQgsOGRProviderSqlite(unittest.TestCase):
|
||||
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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user