Skip to content

Commit

Permalink
[spatialite] Don't skip default values
Browse files Browse the repository at this point in the history
When inserting multiple features in a single prepared statement, the spatialite
provider would skip any default for individual features, even though they have
been specified in the field list, resulting in missing fields.
  • Loading branch information
m-kuhn committed Nov 11, 2016
1 parent fd7f348 commit e6dc522
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3662,9 +3662,6 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )

for ( int i = 0; i < attributevec.count(); ++i )
{
if ( !attributevec.at( i ).isValid() )
continue;

if ( i >= mAttributeFields.count() )
continue;

Expand Down Expand Up @@ -3720,8 +3717,6 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
for ( int i = 0; i < attributevec.count(); ++i )
{
QVariant v = attributevec.at( i );
if ( !v.isValid() )
continue;

// binding values for each attribute
if ( i >= mAttributeFields.count() )
Expand All @@ -3733,7 +3728,11 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )

QVariant::Type type = mAttributeFields.at( i ).type();

if ( v.isNull() )
if ( !v.isValid() )
{
++ia;
}
else if ( v.isNull() )
{
// binding a NULL value
sqlite3_bind_null( stmt, ++ia );
Expand Down

0 comments on commit e6dc522

Please sign in to comment.