Skip to content
Permalink
Browse files
Fix for ticket #161. Always quote the value in an 'UPDATE ... SET = v…
…alue'

SQL statement - the database will ccorrectly interpret the quoted
text based on the data type of the column (e.g., text or numeric).


git-svn-id: http://svn.osgeo.org/qgis/trunk@5601 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jul 14, 2006
1 parent 93730af commit 034609617cdc9bf2b0ab47f45f7369ed7a768daf
Showing with 1 addition and 18 deletions.
  1. +1 −18 src/providers/postgres/qgspostgresprovider.cpp
@@ -1964,24 +1964,7 @@ bool QgsPostgresProvider::changeAttributeValues(std::map<int,std::map<QString,QS
{
for(std::map<QString,QString>::const_iterator siter=(*iter).second.begin();siter!=(*iter).second.end();++siter)
{
QString value=(*siter).second;

//find out, if value contains letters and quote if yes
bool text=false;
for(int i=0;i<value.length();++i)
{
if(value[i].isLetter())
{
text=true;
}
}
if(text)
{
value.prepend("'");
value.append("'");
}

QString sql="UPDATE "+mSchemaTableName+" SET "+(*siter).first+"="+value+" WHERE " +primaryKey+"="+QString::number((*iter).first);
QString sql="UPDATE "+mSchemaTableName+" SET "+(*siter).first+"='"+(*siter).second+"' WHERE " +primaryKey+"="+QString::number((*iter).first);
#ifdef QGISDEBUG
qWarning(sql);
#endif

0 comments on commit 0346096

Please sign in to comment.