[QGIS Commit] r8172 - trunk/qgis/src/providers/postgres

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Feb 21 11:21:43 EST 2008


Author: mhugent
Date: 2008-02-21 11:21:43 -0500 (Thu, 21 Feb 2008)
New Revision: 8172

Modified:
   trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
Log:
Patch from smizuno to fix bug #954. Thanks!

Modified: trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
===================================================================
--- trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp	2008-02-20 17:20:47 UTC (rev 8171)
+++ trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp	2008-02-21 16:21:43 UTC (rev 8172)
@@ -383,7 +383,7 @@
           }
           else
           {
-            char* attribute = PQgetvalue(queryResult, row, PQfnumber(queryResult,*name_it));
+            char* attribute = PQgetvalue(queryResult, row, PQfnumber(queryResult,"\""+*name_it+"\""));
             val = QString::fromUtf8(attribute);
           }
 
@@ -1972,7 +1972,7 @@
   PQexec(connection,"BEGIN");
   for(QgsNewAttributesMap::const_iterator iter=name.begin();iter!=name.end();++iter)
   {
-    QString sql="ALTER TABLE "+mSchemaTableName+" ADD COLUMN "+iter.key()+" "+iter.value();
+    QString sql="ALTER TABLE "+mSchemaTableName+" ADD COLUMN \""+iter.key()+"\" "+iter.value();
 
     QgsDebugMsg(sql);
 
@@ -2006,7 +2006,7 @@
       continue;
     }
     QString column = field_it->name();
-    QString sql="ALTER TABLE "+mSchemaTableName+" DROP COLUMN "+column;
+    QString sql="ALTER TABLE "+mSchemaTableName+" DROP COLUMN \""+column+"\"";
 
     //send sql statement and do error handling
     PGresult* result=PQexec(connection, (const char *)(sql.utf8()));
@@ -2050,7 +2050,7 @@
       // escape quotes
       val.replace("'", "''");
 
-      QString sql="UPDATE "+mSchemaTableName+" SET "+fieldName+"='"+val+"' WHERE \"" +primaryKey+"\"="+QString::number(fid);
+      QString sql="UPDATE "+mSchemaTableName+" SET \""+fieldName+"\"='"+val+"' WHERE \"" +primaryKey+"\"="+QString::number(fid);
       QgsDebugMsg(sql);
 
       // s end sql statement and do error handling



More information about the QGIS-commit mailing list