Hello QGis Users,

in my QGIS Plugin I am filtering layers with this Python code:


LegInt = iface.legendInterface()
layers = LegInt.layers()
TestLayer=None
for layer in layers:
   layerType = layer.type()
   if layer.name() == "my_layer_name":
       s_lay=layer
       break

FeatureIterator = layer.getFeatures( QgsFeatureRequest().setFilterExpression ("Fieldname='SomeValue'") )

for feature in FeatureIterator :
   attrs = feature.attributes()
   print "Feature ID: " + str(feature.id()) + " " + str(attrs)


This works for most layer-types (shapefile, Postgis, personal GDB,etc). But when I tried it with MSSQL Spatial layers, no results are returned. The iterator is empty.

It works if I use the same filter clause (Fieldname='SomeValue') as a Feature subset at Layer-Properties. Then the layer shows only the intended subset.

I work with QGIS 2.2 and 2.4. MSSQL Server is 2008R2. My testdata was exactly the same in Postgis and MSSQL, so I know that the filterexpression is correct.

Could this be a bug?
Can somebody reproduce this?


Have a nice day,
Stefan

_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to