Add test for @parent aggregate filter

This commit is contained in:
Matthias Kuhn 2016-10-25 23:32:58 +02:00
parent c79cf9ae15
commit f292fdd625

View File

@ -1270,6 +1270,8 @@ class TestQgsExpression: public QObject
QTest::newRow( "filter context" ) << "aggregate('test','sum',\"col1\", \"col1\" <= @test_var)" << false << QVariant( 13 );
QTest::newRow( "filter named" ) << "aggregate(layer:='test',aggregate:='sum',expression:=\"col1\", filter:=\"col1\" <= 10)" << false << QVariant( 13 );
QTest::newRow( "filter no matching" ) << "aggregate('test','sum',\"col1\", \"col1\" <= -10)" << false << QVariant( 0 );
QTest::newRow( "filter by @parent attribute" ) << "aggregate(layer:='child_layer', aggregate:='min', expression:=\"col3\", filter:=\"parent\"=attribute(@parent,'col1'))" << false << QVariant( 1 );
}
void aggregate()
@ -1278,6 +1280,9 @@ class TestQgsExpression: public QObject
QgsExpressionContextScope* scope = new QgsExpressionContextScope();
scope->setVariable( QStringLiteral( "test_var" ), 10 );
context << scope;
QgsFeature f;
mAggregatesLayer->getFeatures( "col1 = 4 " ).nextFeature( f );
context.setFeature( f );
QFETCH( QString, string );
QFETCH( bool, evalError );