Skip to content
Permalink
Browse files

[afs] Fix wrong hard-coded OBJECTID reference, use the fetch object i…

…d name
  • Loading branch information
nirvn committed Dec 8, 2018
1 parent f5f4f53 commit be8438b28db717a7fc6eafd2477dc5a61cbdab03
Showing with 33 additions and 1 deletion.
  1. +1 −1 src/providers/arcgisrest/qgsafsshareddata.cpp
  2. +32 −0 tests/src/python/test_provider_afs.py
@@ -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() );
}
@@ -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 """

0 comments on commit be8438b

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