Skip to content
Permalink
Browse files
- Support NULL database values (fixes #987 and #988)
  - 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 5ede092e21deb07049d55c7a68dabfcba976d4fe
@@ -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)
@@ -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
{
@@ -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());
}
}

@@ -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:
Loading

0 comments on commit 5ede092

Please sign in to comment.