Skip to content

Commit

Permalink
- Support NULL database values (fixes #987 and #988)
Browse files Browse the repository at this point in the history
  - check for NULL values on load
  - show "NULL" in attribute table and identify results
  - support entry of "NULL" in attribute table or dialog
- free result of PQexec in postgres provider (fixes memory leaks)


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8217 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 13, 2008
1 parent b8c2a74 commit 5ede092
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 63 deletions.
6 changes: 5 additions & 1 deletion src/app/qgsattributedialog.cpp
Expand Up @@ -67,7 +67,11 @@ QgsAttributeDialog::~QgsAttributeDialog()

QString QgsAttributeDialog::value(int row)
{
return mTable->item(row,1)->text();
QString val = mTable->item(row,1)->text();
if(val=="NULL")
return QString::null;
else
return mTable->item(row,1)->text();
}

bool QgsAttributeDialog::isDirty(int row)
Expand Down
7 changes: 5 additions & 2 deletions src/app/qgsattributetable.cpp
Expand Up @@ -461,7 +461,10 @@ bool QgsAttributeTable::commitChanges(QgsVectorLayer* layer)
fieldIndex = provider->indexFromFieldName(record_it.key());
if(fieldIndex != -1)
{
newAttMap.insert(fieldIndex, record_it.value());
if( record_it.value()=="NULL" )
newAttMap.insert(fieldIndex, QVariant(QString::null) );
else
newAttMap.insert(fieldIndex, record_it.value());
}
else
{
Expand Down Expand Up @@ -572,7 +575,7 @@ void QgsAttributeTable::putFeatureInTable(int row, QgsFeature& fet)
for (it = attr.begin(); it != attr.end(); ++it)
{
// get the field values
setText(row, h++, it->toString());
setText(row, h++, it->isNull() ? "NULL" : it->toString());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolidentify.cpp
Expand Up @@ -303,7 +303,7 @@ void QgsMapToolIdentify::identifyVectorLayer(QgsVectorLayer* layer, const QgsPoi
{
featureNode->setText(1, it->toString());
}
mResults->addAttribute(featureNode, fields[it.key()].name(), it->toString());
mResults->addAttribute(featureNode, fields[it.key()].name(), it->isNull() ? "NULL" : it->toString());
}

// Calculate derived attributes and insert:
Expand Down

0 comments on commit 5ede092

Please sign in to comment.