Skip to content

Commit

Permalink
Fix QgsExpressionNodeColumnRef::prepareNode
Browse files Browse the repository at this point in the history
Look also for the attribute in the feature, as it is done by evalNode()
  • Loading branch information
Hugo Mercier committed Feb 14, 2019
1 parent 8091966 commit ee980ca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/expression/qgsexpressionnodeimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,16 +1261,18 @@ bool QgsExpressionNodeColumnRef::prepareNode( QgsExpression *parent, const QgsEx
QgsFields fields = qvariant_cast<QgsFields>( context->variable( QgsExpressionContext::EXPR_FIELDS ) );

mIndex = fields.lookupField( mName );
if ( mIndex >= 0 )

if ( mIndex == -1 && context->hasFeature() )
{
return true;
mIndex = context->feature().fieldNameIndex( mName );
}
else

if ( mIndex == -1 )
{
parent->setEvalErrorString( tr( "Column '%1' not found" ).arg( mName ) );
mIndex = -1;
return false;
}
return true;
}

QString QgsExpressionNodeColumnRef::dump() const
Expand Down

0 comments on commit ee980ca

Please sign in to comment.