Skip to content
Permalink
Browse files

paste features: don't skip primary key fields, use default value if p…

…resent,

otherwise value of pasted feature (fixes #9489)
  • Loading branch information
jef-n committed Feb 13, 2014
1 parent 28fb634 commit 588d5f425f09039efbb7bd3172d2fc25b39a43d1
Showing with 10 additions and 4 deletions.
  1. +10 −4 src/app/qgisapp.cpp
@@ -5742,11 +5742,9 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
for ( int idx = 0; idx < fields.count(); ++idx )
{
int dst = pasteVectorLayer->fieldNameIndex( fields[idx].name() );
if ( dst < 0 || pkAttrList.contains( dst ) )
{
// skip primary key attributes
if ( dst < 0 )
continue;
}

remap.insert( idx, dst );
}

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

// use default value for primary key fields if it's NOT NULL
if ( pkAttrList.contains( dst ) )
{
dstAttr[ dst ] = pasteVectorLayer->dataProvider()->defaultValue( dst );
if( !dstAttr[ dst ].isNull() )
continue;
}

dstAttr[ dst ] = srcAttr[ src ];
}

0 comments on commit 588d5f4

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