patch_for_bug_954.txt

Steven Mizuno, 2008-02-19 04:10 PM

Download (1.67 KB)

 
1
Index: src/providers/postgres/qgspostgresprovider.cpp
2
===================================================================
3
--- src/providers/postgres/qgspostgresprovider.cpp	(revision 8155)
4
+++ src/providers/postgres/qgspostgresprovider.cpp	(working copy)
5
@@ -383,7 +383,7 @@
6
           }
7
           else
8
           {
9
-            char* attribute = PQgetvalue(queryResult, row, PQfnumber(queryResult,*name_it));
10
+            char* attribute = PQgetvalue(queryResult, row, PQfnumber(queryResult,"\""+*name_it+"\""));
11
             val = QString::fromUtf8(attribute);
12
           }
13
 
14
@@ -1972,7 +1972,7 @@
15
   PQexec(connection,"BEGIN");
16
   for(QgsNewAttributesMap::const_iterator iter=name.begin();iter!=name.end();++iter)
17
   {
18
-    QString sql="ALTER TABLE "+mSchemaTableName+" ADD COLUMN "+iter.key()+" "+iter.value();
19
+    QString sql="ALTER TABLE "+mSchemaTableName+" ADD COLUMN \""+iter.key()+"\" "+iter.value();
20
 
21
     QgsDebugMsg(sql);
22
 
23
@@ -2006,7 +2006,7 @@
24
       continue;
25
     }
26
     QString column = field_it->name();
27
-    QString sql="ALTER TABLE "+mSchemaTableName+" DROP COLUMN "+column;
28
+    QString sql="ALTER TABLE "+mSchemaTableName+" DROP COLUMN \""+column+"\"";
29
 
30
     //send sql statement and do error handling
31
     PGresult* result=PQexec(connection, (const char *)(sql.utf8()));
32
@@ -2050,7 +2050,7 @@
33
       // escape quotes
34
       val.replace("'", "''");
35
 
36
-      QString sql="UPDATE "+mSchemaTableName+" SET "+fieldName+"='"+val+"' WHERE \"" +primaryKey+"\"="+QString::number(fid);
37
+      QString sql="UPDATE "+mSchemaTableName+" SET \""+fieldName+"\"='"+val+"' WHERE \"" +primaryKey+"\"="+QString::number(fid);
38
       QgsDebugMsg(sql);
39
 
40
       // s end sql statement and do error handling