Skip to content
Permalink
Browse files

Named variables for array_foreach

  • Loading branch information
nyalldawson committed Aug 23, 2018
1 parent bb4699e commit de30dc981d1d56c5b92fc0129fa7baa4068bd59c
Showing with 5 additions and 2 deletions.
  1. +4 −1 src/core/expression/qgsexpressionfunction.cpp
  2. +1 −1 tests/src/core/testqgsexpression.cpp
@@ -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" ) )
{

}
@@ -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 ) );

0 comments on commit de30dc9

Please sign in to comment.
You can’t perform that action at this time.