mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Add test for QgsFeatureRequest.setLimit and feature variable
This commit is contained in:
parent
fb849620e7
commit
57a57545a0
@ -15,7 +15,16 @@ __copyright__ = 'Copyright 2015, The QGIS Project'
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
from qgis.core import QgsRectangle, QgsFeatureRequest, QgsFeature, QgsGeometry, QgsAbstractFeatureIterator, NULL
|
||||
from qgis.core import (
|
||||
QgsRectangle,
|
||||
QgsFeatureRequest,
|
||||
QgsFeature,
|
||||
QgsGeometry,
|
||||
QgsAbstractFeatureIterator,
|
||||
QgsExpressionContextScope,
|
||||
QgsExpressionContext,
|
||||
NULL
|
||||
)
|
||||
|
||||
from utilities import(
|
||||
compareWkt
|
||||
@ -190,6 +199,21 @@ class ProviderTestCase(object):
|
||||
# geometry
|
||||
self.assert_query(provider, 'intersects($geometry,geom_from_wkt( \'Polygon ((-72.2 66.1, -65.2 66.1, -65.2 72.0, -72.2 72.0, -72.2 66.1))\'))', [1, 2])
|
||||
|
||||
# combination of an uncompilable expression and limit
|
||||
feature = next(self.vl.getFeatures('pk=4'))
|
||||
context = QgsExpressionContext()
|
||||
scope = QgsExpressionContextScope()
|
||||
scope.setVariable('parent', feature)
|
||||
context.appendScope(scope)
|
||||
|
||||
request = QgsFeatureRequest()
|
||||
request.setExpressionContext(context)
|
||||
request.setFilterExpression('"pk" = attribute(@parent, \'pk\')')
|
||||
request.setLimit(1)
|
||||
|
||||
values = [f['pk'] for f in self.vl.getFeatures(request)]
|
||||
self.assertEqual(values, [4])
|
||||
|
||||
def testGetFeaturesUncompiled(self):
|
||||
self.compiled = False
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user