Skip to content
Permalink
Browse files

add dummy column in case the original layer does not contain an fid-f…

…ield
  • Loading branch information
signedav committed Oct 22, 2018
1 parent 47456e8 commit d9fdf13dcf82b1b49e08516e50dc2bcc41670c44
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/core/qgsofflineediting.cpp
@@ -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 );

0 comments on commit d9fdf13

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