Skip to content

Commit

Permalink
Fix evaluation of expression functions which use optional arguments
Browse files Browse the repository at this point in the history
with null default values
  • Loading branch information
nyalldawson committed Aug 30, 2017
1 parent 0a9e994 commit a73c099
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/expression/qgsexpressionfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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++;
}
}

Expand Down

0 comments on commit a73c099

Please sign in to comment.