From 11c62ca2050c0d6003a512e7b11a2994a531f370 Mon Sep 17 00:00:00 2001 From: Blottiere Paul Date: Tue, 22 Aug 2017 11:07:26 +0100 Subject: [PATCH] A joined feature is added only when one of its field is not null --- src/core/qgsvectorlayer.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index a2f6f139a62..7a196b4607f 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -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 );