Skip to content

Commit d9fdf13

Browse files
committedOct 22, 2018
add dummy column in case the original layer does not contain an fid-field
1 parent 47456e8 commit d9fdf13

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎src/core/qgsofflineediting.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,9 +748,13 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
748748

749749
// NOTE: SpatiaLite provider ignores position of geometry column
750750
// fill gap in QgsAttributeMap if geometry column is not last (WORKAROUND)
751-
int column = 0;
752751
QgsAttributes attrs = f.attributes();
753-
QgsAttributes newAttrs( attrs.count() );
752+
753+
int column = 0;
754+
//newAttrs have an additional attribute (fid), so we have to add a dummy
755+
if ( containerType == GPKG && layer->dataProvider()->fields().lookupField( "fid" ) >= 0 )
756+
column++;
757+
QgsAttributes newAttrs( attrs.count() + column );
754758
for ( int it = 0; it < attrs.count(); ++it )
755759
{
756760
newAttrs[column++] = attrs.at( it );

0 commit comments

Comments
 (0)
Please sign in to comment.