mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fix for ticket #161. Always quote the value in an 'UPDATE ... SET = value'
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
This commit is contained in:
parent
52b808d2df
commit
53c73809b5
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user