Skip to content

Commit 0f07804

Browse files
committed
[spatialite] Add proper support for NULL values
1 parent f4ca526 commit 0f07804

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/providers/spatialite/qgsspatialiteprovider.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -3640,12 +3640,17 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
36403640

36413641
QVariant::Type type = attributeFields[i].type();
36423642

3643-
if ( type == QVariant::Int )
3643+
if ( v.isNull() )
3644+
{
3645+
// binding a NULL value
3646+
sqlite3_bind_null( stmt, ++ia );
3647+
}
3648+
else if ( type == QVariant::Int )
36443649
{
36453650
// binding an INTEGER value
36463651
sqlite3_bind_int( stmt, ++ia, v.toInt() );
36473652
}
3648-
if ( type == QVariant::LongLong )
3653+
else if ( type == QVariant::LongLong )
36493654
{
36503655
// binding a LONGLONG value
36513656
sqlite3_bind_int64( stmt, ++ia, v.toLongLong() );
@@ -3663,7 +3668,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
36633668
}
36643669
else
36653670
{
3666-
// binding a NULL value
3671+
// Unknown type: bind a NULL value
36673672
sqlite3_bind_null( stmt, ++ia );
36683673
}
36693674
}

0 commit comments

Comments
 (0)