[QGIS Commit] r8586 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jun 4 11:00:23 EDT 2008


Author: jef
Date: 2008-06-04 11:00:23 -0400 (Wed, 04 Jun 2008)
New Revision: 8586

Modified:
   trunk/qgis/src/app/qgsdbsourceselect.cpp
Log:
strip current schema from selected tables to match postgres provider behaviour

Modified: trunk/qgis/src/app/qgsdbsourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgsdbsourceselect.cpp	2008-06-04 10:03:07 UTC (rev 8585)
+++ trunk/qgis/src/app/qgsdbsourceselect.cpp	2008-06-04 15:00:23 UTC (rev 8586)
@@ -247,6 +247,14 @@
 {
   m_selectedTables.clear();
 
+  QString currentSchema;
+  QString sql = "select current_schema()";
+  PGresult *result = PQexec(pd, sql.toUtf8());
+  if (result && PQresultStatus(result)==PGRES_TUPLES_OK && PQntuples(result)==1 )
+  {
+    currentSchema = QString::fromUtf8(PQgetvalue(result, 0, 0));
+  }
+
   typedef QMap<int, QVector<QString> > schemaInfo;
   QMap<QString, schemaInfo> dbInfo;
 
@@ -282,7 +290,7 @@
   }
 
   //now traverse all the schemas and table infos
-  QString schemaName, tableName, geomColumnName, sql;
+  QString schemaName, tableName, geomColumnName;
   QString query;
 
   QMap<QString, schemaInfo>::const_iterator schema_it = dbInfo.constBegin();
@@ -324,7 +332,14 @@
           continue;
         }
       }
-      query = "\"" + schemaName + "\".\"" + tableName + "\" " + "(" + geomColumnName + ") sql=" + sql;
+
+      if(schemaName!=currentSchema)
+      {
+	 query += "\"" + schemaName + "\".";
+      }
+
+      query += "\"" + tableName + "\" " + "(" + geomColumnName + ") sql=" + sql;
+
       m_selectedTables.push_back(query);
     }
   }



More information about the QGIS-commit mailing list