Skip to content

Commit

Permalink
Fix for ticket #161. Always quote the value in an 'UPDATE ... SET = v…
Browse files Browse the repository at this point in the history
…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/qgis@5601 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jul 14, 2006
1 parent 52b808d commit 53c7380
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53c7380

Please sign in to comment.