Skip to content

Commit

Permalink
[spatialite] Represent NULL attributes as QVariant/NULL
Browse files Browse the repository at this point in the history
Instead of QVariant/Invalid
  • Loading branch information
m-kuhn committed Aug 28, 2013
1 parent 52ab06e commit 425b8b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/providers/spatialite/qgsspatialitefeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ bool QgsSpatiaLiteFeatureIterator::getFeature( sqlite3_stmt *stmt, QgsFeature &f
else
{
int attrIndex = subsetAttributes ? mRequest.subsetOfAttributes()[ic-1] : ic - 1;
feature.setAttribute( attrIndex, getFeatureAttribute( stmt, ic ) );
feature.setAttribute( attrIndex, getFeatureAttribute( stmt, ic, P->attributeFields[attrIndex].type() ) );
}
}

return true;
}

QVariant QgsSpatiaLiteFeatureIterator::getFeatureAttribute( sqlite3_stmt* stmt, int ic )
QVariant QgsSpatiaLiteFeatureIterator::getFeatureAttribute( sqlite3_stmt* stmt, int ic, const QVariant::Type& type )
{
if ( sqlite3_column_type( stmt, ic ) == SQLITE_INTEGER )
{
Expand All @@ -354,7 +354,7 @@ QVariant QgsSpatiaLiteFeatureIterator::getFeatureAttribute( sqlite3_stmt* stmt,
}

// assuming NULL
return QVariant();
return QVariant( type );
}

void QgsSpatiaLiteFeatureIterator::getFeatureGeometry( sqlite3_stmt* stmt, int ic, QgsFeature& feature )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialitefeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class QgsSpatiaLiteFeatureIterator : public QgsAbstractFeatureIterator
QString quotedPrimaryKey();
bool getFeature( sqlite3_stmt *stmt, QgsFeature &feature );
QString fieldName( const QgsField& fld );
QVariant getFeatureAttribute( sqlite3_stmt* stmt, int ic );
QVariant getFeatureAttribute( sqlite3_stmt* stmt, int ic, const QVariant::Type& type );
void getFeatureGeometry( sqlite3_stmt* stmt, int ic, QgsFeature& feature );

/**
Expand Down

0 comments on commit 425b8b6

Please sign in to comment.