1
0
mirror of https://github.com/qgis/QGIS.git synced 2025-04-26 00:02:43 -04:00

Fix for editing problems

git-svn-id: http://svn.osgeo.org/qgis/trunk@6882 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2007-04-12 07:55:29 +00:00
parent c94d100beb
commit fe77a6ac12
2 changed files with 23 additions and 14 deletions

@ -148,8 +148,8 @@ void QgsMapToolCapture::canvasReleaseEvent(QMouseEvent * e)
f->setGeometryAndOwnership(&wkb[0],size); f->setGeometryAndOwnership(&wkb[0],size);
// add the fields to the QgsFeature // add the fields to the QgsFeature
const QgsFieldMap& fields=provider->fields(); const QgsFieldMap fields=provider->fields();
for(QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it) for(QgsFieldMap::const_iterator it = fields.constBegin(); it != fields.constEnd(); ++it)
{ {
f->addAttribute(it.key(), provider->getDefaultValue(it.key()) ); f->addAttribute(it.key(), provider->getDefaultValue(it.key()) );
} }
@ -371,7 +371,7 @@ void QgsMapToolCapture::canvasReleaseEvent(QMouseEvent * e)
f->setGeometryAndOwnership(&wkb[0],size); f->setGeometryAndOwnership(&wkb[0],size);
// add the fields to the QgsFeature // add the fields to the QgsFeature
const QgsFieldMap& fields = provider->fields(); const QgsFieldMap fields = provider->fields();
for(QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it) for(QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
{ {
f->addAttribute(it.key(), provider->getDefaultValue(it.key())); f->addAttribute(it.key(), provider->getDefaultValue(it.key()));

@ -1549,7 +1549,6 @@ bool QgsPostgresProvider::addFeature(QgsFeature& f, int primaryKeyHighWater)
) )
{ {
charactertype=true; charactertype=true;
break; // no need to continue with this loop
} }
} }
@ -1557,16 +1556,26 @@ bool QgsPostgresProvider::addFeature(QgsFeature& f, int primaryKeyHighWater)
// important: escape quotes in field value // important: escape quotes in field value
fieldvalue.replace("'", "''"); fieldvalue.replace("'", "''");
// XXX isn't it better to always escape field value? //request default value explicitly if fieldvalue is an empty string
if(charactertype) if(fieldvalue.isEmpty())
{ {
insert+="'"; insert += "DEFAULT";
} }
insert+=fieldvalue; else
if(charactertype) {
{ // XXX isn't it better to always escape field value?
insert+="'"; if(charactertype)
} {
insert+="'";
}
insert+=fieldvalue;
if(charactertype)
{
insert+="'";
}
}
} }
} }