Skip to content
Permalink
Browse files

Remove all primary keys when RegeneratePrimaryKey is set, not just th…

…ose for GPKG
  • Loading branch information
nyalldawson committed Oct 15, 2020
1 parent db7b977 commit f0bee04a5ce9bdf0eda0ea9f3fa287223b6327fe
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/core/qgsvectorlayerutils.cpp
@@ -743,12 +743,15 @@ QgsFeatureList QgsVectorLayerUtils::makeFeatureCompatible( const QgsFeature &fea
// Fix attributes
QgsVectorLayerUtils::matchAttributesToFields( newF, layer->fields( ) );

if ( sinkFlags & QgsFeatureSink::RegeneratePrimaryKey && layer->storageType() == QLatin1String( "GPKG" ) )
if ( sinkFlags & QgsFeatureSink::RegeneratePrimaryKey )
{
// drop incoming fid value, let it be regenerated
const int fidIndex = layer->fields().lookupField( QStringLiteral( "fid" ) );
if ( fidIndex >= 0 )
newF.setAttribute( fidIndex, QVariant() );
// drop incoming primary key values, let them be regenerated
const QgsAttributeList pkIndexes = layer->dataProvider()->pkAttributeIndexes();
for ( int index : pkIndexes )
{
if ( index >= 0 )
newF.setAttribute( index, QVariant() );
}
}

// Does geometry need transformations?

0 comments on commit f0bee04

Please sign in to comment.
You can’t perform that action at this time.