Skip to content

Commit

Permalink
Preserve boolean in offline editing
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 14, 2020
1 parent 84563cb commit 60b21f2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -705,6 +705,7 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
const QString fieldName( field.name() );
const QVariant::Type type = field.type();
OGRFieldType ogrType( OFTString );
OGRFieldSubType ogrSubType = OFSTNone;
if ( type == QVariant::Int )
ogrType = OFTInteger;
else if ( type == QVariant::LongLong )
Expand All @@ -717,13 +718,20 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
ogrType = OFTDate;
else if ( type == QVariant::DateTime )
ogrType = OFTDateTime;
else if ( type == QVariant::Bool )
{
ogrType = OFTInteger;
ogrSubType = OFSTBoolean;
}
else
ogrType = OFTString;

int ogrWidth = field.length();

gdal::ogr_field_def_unique_ptr fld( OGR_Fld_Create( fieldName.toUtf8().constData(), ogrType ) );
OGR_Fld_SetWidth( fld.get(), ogrWidth );
if ( ogrSubType != OFSTNone )
OGR_Fld_SetSubType( fld.get(), ogrSubType );

if ( OGR_L_CreateField( hLayer, fld.get(), true ) != OGRERR_NONE )
{
Expand Down

0 comments on commit 60b21f2

Please sign in to comment.