I can't seem to find any reference to this in help or forums, but it seems a da cursor cannot apply a where clause to a layer with a where clause already applied. Does anyone know if this is this working as intended behaviour or a bug?
Here is some test code where this occurred.
This code returned
Here is some test code where this occurred.
import arcpy data = r'D:\GIS\DataBase\misc.gdb\CLI_N' lyr = 'temp' arcpy.MakeFeatureLayer_management(data, lyr, 'OBJECTID < 100') print(arcpy.GetCount_management(lyr)) count = 0 cursor = arcpy.da.SearchCursor(lyr, 'OBJECTID', 'OBJECTID < 10') for _ in cursor: count += 1 print(count)
This code returned
>>> 99 99
Work around for 10.1 involved using a select by attribute on the layer with the where clause then running a cursor without a where clause. So editing the initial example that was broken.
Returns the appropriate.