Skip to content

Commit

Permalink
Fix incorrect attribute index in QgsHanaProvider::addFeatures
Browse files Browse the repository at this point in the history
  • Loading branch information
mrylov committed Dec 7, 2020
1 parent 7ef25b3 commit 0e60950
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/providers/hana/qgshanaprovider.cpp
Expand Up @@ -531,8 +531,6 @@ bool QgsHanaProvider::addFeatures( QgsFeatureList &flist, Flags flags )
}

const QgsAttributes attrs = flist[0].attributes();
const bool hasSkippedFields = attrs.count() != mAttributeFields.size();
QgsDebugMsg( "hasSkippedFields: " + QString::number( hasSkippedFields ) );
QList<int> fieldIds;
int idFieldIndex = -1;

Expand Down Expand Up @@ -606,9 +604,7 @@ bool QgsHanaProvider::addFeatures( QgsFeatureList &flist, Flags flags )
const int fieldIndex = fieldIds[i];
const QgsField &field = mAttributeFields.at( fieldIndex );
const FieldInfo &fieldInfo = mFieldInfos.at( fieldIndex );

const int attrIndex = ( hasSkippedFields ) ? i : fieldIndex;
QVariant attrValue = attrIndex < attrs.length() ? attrs.at( attrIndex ) : QVariant( QVariant::LongLong );
QVariant attrValue = fieldIndex < attrs.length() ? attrs.at( fieldIndex ) : QVariant( QVariant::LongLong );
if ( fieldIndex == idFieldIndex )
{
hasIdValue = !attrValue.isNull();
Expand Down

0 comments on commit 0e60950

Please sign in to comment.