Bug report #10936

setFilterExpression() does not works

Added by Alexander Bruy over 5 years ago. Updated over 5 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Vectors
Affected QGIS version:2.4.0 Regression?:No
Operating System:all Easy fix?:No
Pull Request or Patch supplied:No Resolution:duplicate
Crashes QGIS or corrupts data:No Copied to github as #:19292

Description

QgsFeatureRequest allows advanced features filtering via setFilterExpression() method. But seems this does not work, at least when using from Python.
Here is code snippet:

layer = iface.mapCanvas().currentLayer()
expr = '"dt" = \\'2014-07-05\\' AND abs("y" - 3.0) <= 0.000001'
request = QgsFeatureRequest().setFilterExpression(expr)
for f in layer.getFeatures(request):
  print 'found'

To reproduce:
  1. open attached shapefile and make it active
  2. in Python console execute above code
  3. no features found
  4. now try to use same expression with "Select by Expression" tool, it finds one feature as expected.

See also this thread http://lists.osgeo.org/pipermail/qgis-developer/2014-July/033965.html

test.tar.bz2 - Shapefile for testing (737 Bytes) Alexander Bruy, 2014-07-23 08:42 AM


Related issues

Related to QGIS Application - Bug report #10939: QgsExpression double format Closed 2014-07-24

History

#1 Updated by Matthias Kuhn over 5 years ago

  • Resolution set to duplicate

The real issue is #10939

#2 Updated by Matthias Kuhn over 5 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF