Skip to content

Commit f86a0af

Browse files
author
jef
committed
- 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@8217 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9e7a287 commit f86a0af

File tree

5 files changed

+131
-63
lines changed

5 files changed

+131
-63
lines changed

src/app/qgsattributedialog.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ QgsAttributeDialog::~QgsAttributeDialog()
6767

6868
QString QgsAttributeDialog::value(int row)
6969
{
70-
return mTable->item(row,1)->text();
70+
QString val = mTable->item(row,1)->text();
71+
if(val=="NULL")
72+
return QString::null;
73+
else
74+
return mTable->item(row,1)->text();
7175
}
7276

7377
bool QgsAttributeDialog::isDirty(int row)

src/app/qgsattributetable.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,10 @@ bool QgsAttributeTable::commitChanges(QgsVectorLayer* layer)
461461
fieldIndex = provider->indexFromFieldName(record_it.key());
462462
if(fieldIndex != -1)
463463
{
464-
newAttMap.insert(fieldIndex, record_it.value());
464+
if( record_it.value()=="NULL" )
465+
newAttMap.insert(fieldIndex, QVariant(QString::null) );
466+
else
467+
newAttMap.insert(fieldIndex, record_it.value());
465468
}
466469
else
467470
{
@@ -572,7 +575,7 @@ void QgsAttributeTable::putFeatureInTable(int row, QgsFeature& fet)
572575
for (it = attr.begin(); it != attr.end(); ++it)
573576
{
574577
// get the field values
575-
setText(row, h++, it->toString());
578+
setText(row, h++, it->isNull() ? "NULL" : it->toString());
576579
}
577580
}
578581

src/app/qgsmaptoolidentify.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void QgsMapToolIdentify::identifyVectorLayer(QgsVectorLayer* layer, const QgsPoi
303303
{
304304
featureNode->setText(1, it->toString());
305305
}
306-
mResults->addAttribute(featureNode, fields[it.key()].name(), it->toString());
306+
mResults->addAttribute(featureNode, fields[it.key()].name(), it->isNull() ? "NULL" : it->toString());
307307
}
308308

309309
// Calculate derived attributes and insert:

0 commit comments

Comments
 (0)