Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
strip current schema from selected tables to match postgres provider …
…behaviour

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8586 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 4, 2008
1 parent 3954774 commit 3690acc
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/app/qgsdbsourceselect.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 3690acc

Please sign in to comment.