Skip to content

Commit

Permalink
A joined feature is added only when one of its field is not null
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Aug 28, 2017
1 parent 927dea3 commit 11c62ca
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/core/qgsvectorlayer.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 11c62ca

Please sign in to comment.