Skip to content

Commit

Permalink
[afs] Fix wrong hard-coded OBJECTID reference, use the fetch object i…
Browse files Browse the repository at this point in the history
…d name
  • Loading branch information
nirvn committed Dec 10, 2018
1 parent f5f4f53 commit be8438b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/providers/arcgisrest/qgsafsshareddata.cpp
Expand Up @@ -120,7 +120,7 @@ bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, const QgsRect
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() ) );
}
attributes[idx] = attribute;
if ( mFields.at( idx ).name() == QStringLiteral( "OBJECTID" ) )
if ( mFields.at( idx ).name() == mObjectIdFieldName )
{
featureId = startId + objectIds.indexOf( attributesData[mFields.at( idx ).name()].toInt() );
}
Expand Down
32 changes: 32 additions & 0 deletions tests/src/python/test_provider_afs.py
Expand Up @@ -463,10 +463,42 @@ def testObjectIdDifferentName(self):
}
""".encode('UTF-8'))

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:
f.write("""
{
"displayFieldName": "LABEL",
"geometryType": "esriGeometryPoint",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"fields":[{"name":"OBJECTID1","type":"esriFieldTypeOID","alias":"OBJECTID1","domain":null},
{"name":"pk","type":"esriFieldTypeInteger","alias":"pk","domain":null},
{"name":"cnt","type":"esriFieldTypeInteger","alias":"cnt","domain":null},
{"name":"Shape","type":"esriFieldTypeGeometry","alias":"Shape","domain":null}],
"features": [
{
"attributes": {
"OBJECTID1": 5,
"pk": 5,
"cnt": -200,
"name": null
},
"geometry": {
"x": -71.123,
"y": 78.23
}
}
]
}""".encode('UTF-8'))

# Create test layer
vl = QgsVectorLayer("url='http://" + endpoint + "' crs='epsg:4326'", 'test', 'arcgisfeatureserver')
assert vl.isValid()

f = vl.getFeature(0)
assert f.isValid()

def testDateTime(self):
""" Test that datetime fields work correctly """

Expand Down

0 comments on commit be8438b

Please sign in to comment.