A joined feature is added only when one of its field is not null

This commit is contained in:
Blottiere Paul 2017-08-22 11:07:26 +01:00
parent 927dea3c18
commit 11c62ca205

View File

@ -2718,7 +2718,24 @@ bool QgsVectorLayer::addFeaturesToJoinedLayers( QgsFeatureList &features, Flags
joinLayer->updateFeature( existingFeature );
}
else
joinFeatures << joinFeature;
{
// joined feature is added only if one of its field is not null
bool notNullFields = false;
Q_FOREACH ( const QgsField &field, joinFeature.fields() )
{
if ( field.name() == info.joinFieldName() )
continue;
if ( !joinFeature.attribute( field.name() ).isNull() )
{
notNullFields = true;
break;
}
}
if ( notNullFields )
joinFeatures << joinFeature;
}
}
joinLayer->addFeatures( joinFeatures );