Skip to content

Commit 588d5f4

Browse files
committed
paste features: don't skip primary key fields, use default value if present,
otherwise value of pasted feature (fixes #9489)
1 parent 28fb634 commit 588d5f4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/app/qgisapp.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5742,11 +5742,9 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
57425742
for ( int idx = 0; idx < fields.count(); ++idx )
57435743
{
57445744
int dst = pasteVectorLayer->fieldNameIndex( fields[idx].name() );
5745-
if ( dst < 0 || pkAttrList.contains( dst ) )
5746-
{
5747-
// skip primary key attributes
5745+
if ( dst < 0 )
57485746
continue;
5749-
}
5747+
57505748
remap.insert( idx, dst );
57515749
}
57525750

@@ -5763,6 +5761,14 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
57635761
if ( dst < 0 )
57645762
continue;
57655763

5764+
// use default value for primary key fields if it's NOT NULL
5765+
if ( pkAttrList.contains( dst ) )
5766+
{
5767+
dstAttr[ dst ] = pasteVectorLayer->dataProvider()->defaultValue( dst );
5768+
if( !dstAttr[ dst ].isNull() )
5769+
continue;
5770+
}
5771+
57665772
dstAttr[ dst ] = srcAttr[ src ];
57675773
}
57685774

0 commit comments

Comments
 (0)