Skip to content

Commit

Permalink
Check fields origin
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 authored and nyalldawson committed Sep 28, 2021
1 parent e9fd2dd commit 9fdc868
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/core/vector/qgsvectorlayerjoinbuffer.cpp
Expand Up @@ -175,9 +175,22 @@ void QgsVectorLayerJoinBuffer::cacheJoinLayer( QgsVectorLayerJoinInfo &joinInfo
QgsAttributes attributesCache;
for ( int i = 0; i < attrs.size(); i++ )
{
if ( i != joinFieldIndex
&& !mLayer->fields().names().contains( cacheLayer->fields().names().at( i ) ) )
attributesCache.append( attrs.at( i ) );
if ( i == joinFieldIndex )
continue;

if ( !joinInfo.prefix().isNull() ) // Default prefix 'layerName_' used
{
// Joined field name
const QString joinFieldName = joinInfo.prefix() + cacheLayer->fields().names().at( i );

// Check for name collisions
int fieldIndex = mLayer->fields().indexFromName( joinFieldName );
if ( fieldIndex >= 0
&& mLayer->fields().fieldOrigin( fieldIndex ) != QgsFields::OriginJoin )
continue;
}

attributesCache.append( attrs.at( i ) );
}
joinInfo.cachedAttributes.insert( key, attributesCache );
}
Expand Down

0 comments on commit 9fdc868

Please sign in to comment.