Skip to content

Commit

Permalink
Fix for editing problems
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@6882 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 12, 2007
1 parent c94d100 commit fe77a6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/app/qgsmaptoolcapture.cpp
Expand Up @@ -148,8 +148,8 @@ void QgsMapToolCapture::canvasReleaseEvent(QMouseEvent * e)

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

// 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)
{
f->addAttribute(it.key(), provider->getDefaultValue(it.key()));
Expand Down
31 changes: 20 additions & 11 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -1549,24 +1549,33 @@ bool QgsPostgresProvider::addFeature(QgsFeature& f, int primaryKeyHighWater)
)
{
charactertype=true;
break; // no need to continue with this loop
}

}

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

// XXX isn't it better to always escape field value?
if(charactertype)
{
insert+="'";
}
insert+=fieldvalue;
if(charactertype)
{
insert+="'";
}
//request default value explicitly if fieldvalue is an empty string
if(fieldvalue.isEmpty())
{
insert += "DEFAULT";
}
else
{
// XXX isn't it better to always escape field value?
if(charactertype)
{
insert+="'";
}

insert+=fieldvalue;

if(charactertype)
{
insert+="'";
}
}
}
}

Expand Down

0 comments on commit fe77a6a

Please sign in to comment.