Skip to content

Commit be8438b

Browse files
committed
[afs] Fix wrong hard-coded OBJECTID reference, use the fetch object id name
1 parent f5f4f53 commit be8438b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/providers/arcgisrest/qgsafsshareddata.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, const QgsRect
120120
QgsDebugMsg( QStringLiteral( "Invalid value %1 for field %2 of type %3" ).arg( attributesData[mFields.at( idx ).name()].toString(), mFields.at( idx ).name(), mFields.at( idx ).typeName() ) );
121121
}
122122
attributes[idx] = attribute;
123-
if ( mFields.at( idx ).name() == QStringLiteral( "OBJECTID" ) )
123+
if ( mFields.at( idx ).name() == mObjectIdFieldName )
124124
{
125125
featureId = startId + objectIds.indexOf( attributesData[mFields.at( idx ).name()].toInt() );
126126
}

tests/src/python/test_provider_afs.py

+32
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,42 @@ def testObjectIdDifferentName(self):
463463
}
464464
""".encode('UTF-8'))
465465

466+
with open(sanitize(endpoint, '/query?f=json&objectIds=5,3,1,2,4&inSR=4326&outSR=4326&returnGeometry=true&outFields=OBJECTID1,pk,cnt&returnM=false&returnZ=false'), 'wb') as f:
467+
f.write("""
468+
{
469+
"displayFieldName": "LABEL",
470+
"geometryType": "esriGeometryPoint",
471+
"spatialReference": {
472+
"wkid": 4326,
473+
"latestWkid": 4326
474+
},
475+
"fields":[{"name":"OBJECTID1","type":"esriFieldTypeOID","alias":"OBJECTID1","domain":null},
476+
{"name":"pk","type":"esriFieldTypeInteger","alias":"pk","domain":null},
477+
{"name":"cnt","type":"esriFieldTypeInteger","alias":"cnt","domain":null},
478+
{"name":"Shape","type":"esriFieldTypeGeometry","alias":"Shape","domain":null}],
479+
"features": [
480+
{
481+
"attributes": {
482+
"OBJECTID1": 5,
483+
"pk": 5,
484+
"cnt": -200,
485+
"name": null
486+
},
487+
"geometry": {
488+
"x": -71.123,
489+
"y": 78.23
490+
}
491+
}
492+
]
493+
}""".encode('UTF-8'))
494+
466495
# Create test layer
467496
vl = QgsVectorLayer("url='http://" + endpoint + "' crs='epsg:4326'", 'test', 'arcgisfeatureserver')
468497
assert vl.isValid()
469498

499+
f = vl.getFeature(0)
500+
assert f.isValid()
501+
470502
def testDateTime(self):
471503
""" Test that datetime fields work correctly """
472504

0 commit comments

Comments
 (0)