Skip to content

Commit

Permalink
Named variables for array_foreach
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 23, 2018
1 parent bb4699e commit de30dc9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -4776,7 +4776,10 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
}

QgsArrayForeachExpressionFunction::QgsArrayForeachExpressionFunction()
: QgsExpressionFunction( QStringLiteral( "array_foreach" ), 2, QCoreApplication::tr( "Arrays" ) )
: QgsExpressionFunction( QStringLiteral( "array_foreach" ), QgsExpressionFunction::ParameterList()
<< QgsExpressionFunction::Parameter( QStringLiteral( "array" ) )
<< QgsExpressionFunction::Parameter( QStringLiteral( "expression" ) ),
QCoreApplication::tr( "Arrays" ) )
{

}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsexpression.cpp
Expand Up @@ -2689,7 +2689,7 @@ class TestQgsExpression: public QObject

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

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

0 comments on commit de30dc9

Please sign in to comment.