Skip to content

Commit de30dc9

Browse files
committedAug 23, 2018
Named variables for array_foreach
1 parent bb4699e commit de30dc9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎src/core/expression/qgsexpressionfunction.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4776,7 +4776,10 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
47764776
}
47774777

47784778
QgsArrayForeachExpressionFunction::QgsArrayForeachExpressionFunction()
4779-
: QgsExpressionFunction( QStringLiteral( "array_foreach" ), 2, QCoreApplication::tr( "Arrays" ) )
4779+
: QgsExpressionFunction( QStringLiteral( "array_foreach" ), QgsExpressionFunction::ParameterList()
4780+
<< QgsExpressionFunction::Parameter( QStringLiteral( "array" ) )
4781+
<< QgsExpressionFunction::Parameter( QStringLiteral( "expression" ) ),
4782+
QCoreApplication::tr( "Arrays" ) )
47804783
{
47814784

47824785
}

‎tests/src/core/testqgsexpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2689,7 +2689,7 @@ class TestQgsExpression: public QObject
26892689

26902690
QVariantList foreachExpected;
26912691
foreachExpected << QStringLiteral( "ABC" ) << QStringLiteral( "HELLO" );
2692-
QCOMPARE( QgsExpression( "array_foreach(array('abc', 'hello'), upper(@element))" ).evaluate( &context ), QVariant( foreachExpected ) );
2692+
QCOMPARE( QgsExpression( "array_foreach(array:=array('abc', 'hello'), expression:=upper(@element))" ).evaluate( &context ), QVariant( foreachExpected ) );
26932693

26942694
QCOMPARE( QgsExpression( "array_intersect(array('1', '2', '3', '4'), array('4', '0', '2', '5'))" ).evaluate( &context ), QVariant( true ) );
26952695
QCOMPARE( QgsExpression( "array_intersect(array('1', '2', '3', '4'), array('0', '5'))" ).evaluate( &context ), QVariant( false ) );

0 commit comments

Comments
 (0)
Please sign in to comment.