@@ -111,7 +111,7 @@ def setUpClass(cls):
111
111
"supportsAdvancedQueries":true,"supportedQueryFormats":"JSON, AMF",
112
112
"ownershipBasedAccessControlForFeatures":{"allowOthersToQuery":true},"useStandardizedQueries":true}""" .encode ('UTF-8' ))
113
113
114
- with open (sanitize (endpoint , '/query?f=json_where=objectid=objectid_returnIdsOnly =true' ), 'wb' ) as f :
114
+ with open (sanitize (endpoint , '/query?f=json_where=OBJECTID=OBJECTID_returnIdsOnly =true' ), 'wb' ) as f :
115
115
f .write ("""
116
116
{
117
117
"objectIdFieldName": "OBJECTID",
@@ -312,7 +312,7 @@ def setUpClass(cls):
312
312
]
313
313
}""" .encode ('UTF-8' ))
314
314
315
- with open (sanitize (endpoint , '/query?f=json&where=objectid=objectid &returnIdsOnly=true&geometry=-70.000000,67.000000,-60.000000,80.000000&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelEnvelopeIntersects' ), 'wb' ) as f :
315
+ with open (sanitize (endpoint , '/query?f=json&where=OBJECTID=OBJECTID &returnIdsOnly=true&geometry=-70.000000,67.000000,-60.000000,80.000000&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelEnvelopeIntersects' ), 'wb' ) as f :
316
316
f .write ("""
317
317
{
318
318
"objectIdFieldName": "OBJECTID",
@@ -323,7 +323,7 @@ def setUpClass(cls):
323
323
}
324
324
""" .encode ('UTF-8' ))
325
325
326
- with open (sanitize (endpoint , '/query?f=json&where=objectid=objectid &returnIdsOnly=true&geometry=-73.000000,70.000000,-63.000000,80.000000&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelEnvelopeIntersects' ), 'wb' ) as f :
326
+ with open (sanitize (endpoint , '/query?f=json&where=OBJECTID=OBJECTID &returnIdsOnly=true&geometry=-73.000000,70.000000,-63.000000,80.000000&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelEnvelopeIntersects' ), 'wb' ) as f :
327
327
f .write ("""
328
328
{
329
329
"objectIdFieldName": "OBJECTID",
@@ -334,7 +334,7 @@ def setUpClass(cls):
334
334
}
335
335
""" .encode ('UTF-8' ))
336
336
337
- with open (sanitize (endpoint , '/query?f=json&where=objectid=objectid &returnIdsOnly=true&geometry=-68.721119,68.177676,-64.678700,79.123755&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelEnvelopeIntersects' ), 'wb' ) as f :
337
+ with open (sanitize (endpoint , '/query?f=json&where=OBJECTID=OBJECTID &returnIdsOnly=true&geometry=-68.721119,68.177676,-64.678700,79.123755&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelEnvelopeIntersects' ), 'wb' ) as f :
338
338
f .write ("""
339
339
{
340
340
"objectIdFieldName": "OBJECTID",
@@ -366,6 +366,47 @@ def testGetFeaturesNoGeometry(self):
366
366
"""
367
367
pass
368
368
369
+ def testObjectIdDifferentName (self ):
370
+ """ Test that object id fields not named OBJECTID work correctly """
371
+
372
+ endpoint = self .basetestpath + '/oid_fake_qgis_http_endpoint'
373
+ with open (sanitize (endpoint , '?f=json' ), 'wb' ) as f :
374
+ f .write ("""
375
+ {"currentVersion":10.22,"id":1,"name":"QGIS Test","type":"Feature Layer","description":
376
+ "QGIS Provider Test Layer.\n ","geometryType":"esriGeometryPoint","copyrightText":"","parentLayer":{"id":0,"name":"QGIS Tests"},"subLayers":[],
377
+ "minScale":72225,"maxScale":0,
378
+ "defaultVisibility":true,
379
+ "extent":{"xmin":-71.123,"ymin":66.33,"xmax":-65.32,"ymax":78.3,
380
+ "spatialReference":{"wkid":4326,"latestWkid":4326}},
381
+ "hasAttachments":false,"htmlPopupType":"esriServerHTMLPopupTypeAsHTMLText",
382
+ "displayField":"LABEL","typeIdField":null,
383
+ "fields":[{"name":"OBJECTID1","type":"esriFieldTypeOID","alias":"OBJECTID","domain":null},
384
+ {"name":"pk","type":"esriFieldTypeInteger","alias":"pk","domain":null},
385
+ {"name":"cnt","type":"esriFieldTypeInteger","alias":"cnt","domain":null}],
386
+ "relationships":[],"canModifyLayer":false,"canScaleSymbols":false,"hasLabels":false,
387
+ "capabilities":"Map,Query,Data","maxRecordCount":1000,"supportsStatistics":true,
388
+ "supportsAdvancedQueries":true,"supportedQueryFormats":"JSON, AMF",
389
+ "ownershipBasedAccessControlForFeatures":{"allowOthersToQuery":true},"useStandardizedQueries":true}""" .encode (
390
+ 'UTF-8' ))
391
+
392
+ with open (sanitize (endpoint , '/query?f=json_where=OBJECTID1=OBJECTID1_returnIdsOnly=true' ), 'wb' ) as f :
393
+ f .write ("""
394
+ {
395
+ "objectIdFieldName": "OBJECTID1",
396
+ "objectIds": [
397
+ 5,
398
+ 3,
399
+ 1,
400
+ 2,
401
+ 4
402
+ ]
403
+ }
404
+ """ .encode ('UTF-8' ))
405
+
406
+ # Create test layer
407
+ vl = QgsVectorLayer ("url='http://" + endpoint + "' crs='epsg:4326'" , 'test' , 'arcgisfeatureserver' )
408
+ assert vl .isValid ()
409
+
369
410
370
411
if __name__ == '__main__' :
371
412
unittest .main ()
0 commit comments