Skip to content

Commit d1172d4

Browse files
committedOct 22, 2018
care for types of fid
1 parent d9fdf13 commit d1172d4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎src/core/qgsofflineediting.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,15 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
749749
// NOTE: SpatiaLite provider ignores position of geometry column
750750
// fill gap in QgsAttributeMap if geometry column is not last (WORKAROUND)
751751
QgsAttributes attrs = f.attributes();
752-
753752
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 )
753+
int indexOfFid = layer->dataProvider()->fields().lookupField( "fid" );
754+
if ( containerType == GPKG && ( indexOfFid == -1 || ( layer->dataProvider()->fields().at( indexOfFid ).type() != QVariant::Int
755+
&& layer->dataProvider()->fields().at( indexOfFid ).type() != QVariant::LongLong ) ) )
756+
{
757+
// newAttrs (1) has an additional attribute (fid) that is (2) of the correct type
758+
// so we have to add a dummy because otherwise it messes up with the amount of attributes
756759
column++;
760+
}
757761
QgsAttributes newAttrs( attrs.count() + column );
758762
for ( int it = 0; it < attrs.count(); ++it )
759763
{

0 commit comments

Comments
 (0)