Skip to content
Permalink
Browse files

Use QgsFields::fieldNameIndex when preparing column refs in expressions

Fixes handling of duplicate field names with different case in
expressions

(cherry-picked from 0a84fbd)
  • Loading branch information
nyalldawson committed Feb 23, 2016
1 parent 20e9d64 commit ec0b6c96b5f1cc93bfcd5f4452772cb0dc1976ec
Showing with 9 additions and 9 deletions.
  1. +9 −9 src/core/qgsexpression.cpp
@@ -2720,17 +2720,17 @@ QVariant QgsExpression::NodeColumnRef::eval( QgsExpression* /*parent*/, const Qg

bool QgsExpression::NodeColumnRef::prepare( QgsExpression* parent, const QgsFields& fields )
{
for ( int i = 0; i < fields.count(); ++i )
mIndex = fields.fieldNameIndex( mName );
if ( mIndex >= 0 )
{
if ( QString::compare( fields[i].name(), mName, Qt::CaseInsensitive ) == 0 )
{
mIndex = i;
return true;
}
return true;
}
else
{
parent->mEvalErrorString = QObject::tr( "Column '%1' not found" ).arg( mName );
mIndex = -1;
return false;
}
parent->mEvalErrorString = QObject::tr( "Column '%1' not found" ).arg( mName );
mIndex = -1;
return false;
}

QString QgsExpression::NodeColumnRef::dump() const

0 comments on commit ec0b6c9

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