Skip to content

Commit

Permalink
When evaluating an expression with a missing referenced field, this w…
Browse files Browse the repository at this point in the history
…ill be replaced with [fieldname].

When calculating data defined values, this will be counterproductive.
A field with a data defined value might work well in the expression builder (because fiels are all present) but fail in the legend, because it's rendered with no feature and hence fields. With this change, we can at least use `try("fieldname", 0)` to fallback to a default value.
  • Loading branch information
m-kuhn committed Dec 7, 2019
1 parent 3bf8d96 commit e1b016b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/expression/qgsexpressionnodeimpl.cpp
Expand Up @@ -1270,7 +1270,8 @@ QVariant QgsExpressionNodeColumnRef::evalNode( QgsExpression *parent, const QgsE
return feature.attribute( mName );
}
}
return QVariant( '[' + mName + ']' );
parent->setEvalErrorString( QStringLiteral( "Column '%1' not found" ).arg( mName ) );
return QVariant();
}

QgsExpressionNode::NodeType QgsExpressionNodeColumnRef::nodeType() const
Expand Down

0 comments on commit e1b016b

Please sign in to comment.