Skip to content

Commit 61db810

Browse files
author
Hugo Mercier
committed
Fix QgsExpressionNodeColumnRef::prepareNode
Look also for the attribute in the feature, as it is done by evalNode()
1 parent aaed9ff commit 61db810

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/core/expression/qgsexpressionnodeimpl.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1261,16 +1261,18 @@ bool QgsExpressionNodeColumnRef::prepareNode( QgsExpression *parent, const QgsEx
12611261
QgsFields fields = qvariant_cast<QgsFields>( context->variable( QgsExpressionContext::EXPR_FIELDS ) );
12621262

12631263
mIndex = fields.lookupField( mName );
1264-
if ( mIndex >= 0 )
1264+
1265+
if ( mIndex == -1 && context->hasFeature() )
12651266
{
1266-
return true;
1267+
mIndex = context->feature().fieldNameIndex( mName );
12671268
}
1268-
else
1269+
1270+
if ( mIndex == -1 )
12691271
{
12701272
parent->setEvalErrorString( tr( "Column '%1' not found" ).arg( mName ) );
1271-
mIndex = -1;
12721273
return false;
12731274
}
1275+
return true;
12741276
}
12751277

12761278
QString QgsExpressionNodeColumnRef::dump() const

0 commit comments

Comments
 (0)