Skip to content
Permalink
Browse files

strip current schema from selected tables to match postgres provider …

…behaviour

git-svn-id: http://svn.osgeo.org/qgis/trunk@8586 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Jun 4, 2008
1 parent 215e7ca commit 59f2ba35e36fbbe0fb063d0c6e174c846e054fee
Showing with 17 additions and 2 deletions.
  1. +17 −2 src/app/qgsdbsourceselect.cpp
@@ -247,6 +247,14 @@ void QgsDbSourceSelect::addTables()
{
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 @@ void QgsDbSourceSelect::addTables()
}

//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 @@ void QgsDbSourceSelect::addTables()
continue;
}
}
query = "\"" + schemaName + "\".\"" + tableName + "\" " + "(" + geomColumnName + ") sql=" + sql;

if(schemaName!=currentSchema)
{
query += "\"" + schemaName + "\".";
}

query += "\"" + tableName + "\" " + "(" + geomColumnName + ") sql=" + sql;

m_selectedTables.push_back(query);
}
}

0 comments on commit 59f2ba3

Please sign in to comment.
You can’t perform that action at this time.