Skip to content

Commit fe77a6a

Browse files
author
mhugent
committedApr 12, 2007
Fix for editing problems
git-svn-id: http://svn.osgeo.org/qgis/trunk@6882 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent c94d100 commit fe77a6a

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed
 

‎src/app/qgsmaptoolcapture.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ void QgsMapToolCapture::canvasReleaseEvent(QMouseEvent * e)
148148

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

373373
// add the fields to the QgsFeature
374-
const QgsFieldMap& fields = provider->fields();
374+
const QgsFieldMap fields = provider->fields();
375375
for(QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
376376
{
377377
f->addAttribute(it.key(), provider->getDefaultValue(it.key()));

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,24 +1549,33 @@ bool QgsPostgresProvider::addFeature(QgsFeature& f, int primaryKeyHighWater)
15491549
)
15501550
{
15511551
charactertype=true;
1552-
break; // no need to continue with this loop
15531552
}
15541553

15551554
}
15561555

15571556
// important: escape quotes in field value
15581557
fieldvalue.replace("'", "''");
15591558

1560-
// XXX isn't it better to always escape field value?
1561-
if(charactertype)
1562-
{
1563-
insert+="'";
1564-
}
1565-
insert+=fieldvalue;
1566-
if(charactertype)
1567-
{
1568-
insert+="'";
1569-
}
1559+
//request default value explicitly if fieldvalue is an empty string
1560+
if(fieldvalue.isEmpty())
1561+
{
1562+
insert += "DEFAULT";
1563+
}
1564+
else
1565+
{
1566+
// XXX isn't it better to always escape field value?
1567+
if(charactertype)
1568+
{
1569+
insert+="'";
1570+
}
1571+
1572+
insert+=fieldvalue;
1573+
1574+
if(charactertype)
1575+
{
1576+
insert+="'";
1577+
}
1578+
}
15701579
}
15711580
}
15721581

0 commit comments

Comments
 (0)
Please sign in to comment.