Skip to content

Commit 802c3b1

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

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
@@ -454,10 +454,42 @@ def testObjectIdDifferentName(self):
454454
}
455455
""".encode('UTF-8'))
456456

457+
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:
458+
f.write("""
459+
{
460+
"displayFieldName": "LABEL",
461+
"geometryType": "esriGeometryPoint",
462+
"spatialReference": {
463+
"wkid": 4326,
464+
"latestWkid": 4326
465+
},
466+
"fields":[{"name":"OBJECTID1","type":"esriFieldTypeOID","alias":"OBJECTID1","domain":null},
467+
{"name":"pk","type":"esriFieldTypeInteger","alias":"pk","domain":null},
468+
{"name":"cnt","type":"esriFieldTypeInteger","alias":"cnt","domain":null},
469+
{"name":"Shape","type":"esriFieldTypeGeometry","alias":"Shape","domain":null}],
470+
"features": [
471+
{
472+
"attributes": {
473+
"OBJECTID1": 5,
474+
"pk": 5,
475+
"cnt": -200,
476+
"name": null
477+
},
478+
"geometry": {
479+
"x": -71.123,
480+
"y": 78.23
481+
}
482+
}
483+
]
484+
}""".encode('UTF-8'))
485+
457486
# Create test layer
458487
vl = QgsVectorLayer("url='http://" + endpoint + "' crs='epsg:4326'", 'test', 'arcgisfeatureserver')
459488
assert vl.isValid()
460489

490+
f = vl.getFeature(0)
491+
assert f.isValid()
492+
461493
def testDateTime(self):
462494
""" Test that datetime fields work correctly """
463495

0 commit comments

Comments
 (0)