Skip to content

Commit

Permalink
add dummy column in case the original layer does not contain an fid-f…
Browse files Browse the repository at this point in the history
…ield
  • Loading branch information
signedav committed Oct 22, 2018
1 parent 47456e8 commit d9fdf13
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -748,9 +748,13 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit

// NOTE: SpatiaLite provider ignores position of geometry column
// fill gap in QgsAttributeMap if geometry column is not last (WORKAROUND)
int column = 0;
QgsAttributes attrs = f.attributes();
QgsAttributes newAttrs( attrs.count() );

int column = 0;
//newAttrs have an additional attribute (fid), so we have to add a dummy
if ( containerType == GPKG && layer->dataProvider()->fields().lookupField( "fid" ) >= 0 )
column++;
QgsAttributes newAttrs( attrs.count() + column );
for ( int it = 0; it < attrs.count(); ++it )
{
newAttrs[column++] = attrs.at( it );
Expand Down

0 comments on commit d9fdf13

Please sign in to comment.