Skip to content
Permalink
Browse files

Used named parameters for with_variable function

  • Loading branch information
nyalldawson committed Aug 23, 2018
1 parent 34bb08c commit 89cd7858e54db2e19b8ce151952034a093ea801f
@@ -5,7 +5,7 @@
"arguments": [
{"arg":"name","description":"the name of the variable to set"},
{"arg":"value","description":"the value to set"},
{"arg":"node","description":"the expression for which the variable will be available"}
{"arg":"expression","description":"the expression for which the variable will be available"}
],
"examples": [ { "expression":"with_variable('my_sum', 1 + 2 + 3, @my_sum * 2 + @my_sum * 5)", "returns":"42"}]
}
@@ -4863,7 +4863,11 @@ bool QgsArrayForeachExpressionFunction::prepare( const QgsExpressionNodeFunction
}

QgsWithVariableExpressionFunction::QgsWithVariableExpressionFunction()
: QgsExpressionFunction( QStringLiteral( "with_variable" ), 3, QCoreApplication::tr( "General" ) )
: QgsExpressionFunction( QStringLiteral( "with_variable" ), QgsExpressionFunction::ParameterList() <<
QgsExpressionFunction::Parameter( QStringLiteral( "name" ) )
<< QgsExpressionFunction::Parameter( QStringLiteral( "value" ) )
<< QgsExpressionFunction::Parameter( QStringLiteral( "expression" ) ),
QCoreApplication::tr( "General" ) )
{

}
@@ -1287,7 +1287,7 @@ class TestQgsExpression: public QObject
QTest::newRow( "'a' not like 'a%'" ) << QStringLiteral( "'a' not like 'a%'" ) << false << QVariant( 0 );

// with_variable
QTest::newRow( "with_variable('five', 5, @five * 2)" ) << QStringLiteral( "with_variable('five', 5, @five * 2)" ) << false << QVariant( 10 );
QTest::newRow( "with_variable(name:='five', value:=5, expression:=@five * 2)" ) << QStringLiteral( "with_variable(name:='five', value:=5, expression:=@five * 2)" ) << false << QVariant( 10 );
QTest::newRow( "with_variable('nothing', NULL, COALESCE(@nothing, 'something'))" ) << QStringLiteral( "with_variable('nothing', NULL, COALESCE(@nothing, 'something'))" ) << false << QVariant( "something" );

// array_first, array_last

0 comments on commit 89cd785

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