Skip to content
Permalink
Browse files

Fix evaluation of expression functions which use optional arguments

with null default values
  • Loading branch information
nyalldawson committed Aug 30, 2017
1 parent 0a9e994 commit a73c099835503250ef0c6018cb2a2c8bd2e7207a
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/core/expression/qgsexpressionfunction.cpp
@@ -53,6 +53,7 @@ QVariant QgsExpressionFunction::run( QgsExpressionNode::NodeList *args, const Qg
QVariantList argValues;
if ( args )
{
int arg = 0;
Q_FOREACH ( QgsExpressionNode *n, args->list() )
{
QVariant v;
@@ -65,10 +66,12 @@ QVariant QgsExpressionFunction::run( QgsExpressionNode::NodeList *args, const Qg
{
v = n->eval( parent, context );
ENSURE_NO_EVAL_ERROR;
if ( QgsExpressionUtils::isNull( v ) && !handlesNull() )
bool defaultParamIsNull = mParameterList.count() > arg && mParameterList.at( arg ).optional() && !mParameterList.at( arg ).defaultValue().isValid();
if ( QgsExpressionUtils::isNull( v ) && !defaultParamIsNull && !handlesNull() )
return QVariant(); // all "normal" functions return NULL, when any QgsExpressionFunction::Parameter is NULL (so coalesce is abnormal)
}
argValues.append( v );
arg++;
}
}

0 comments on commit a73c099

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