Skip to content
Permalink
Browse files

Fix for ticket #431 (postgres tables not visible in query builder).

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6203 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m
g_j_m committed Dec 7, 2006
1 parent 51707cc commit b0517be697c62489b042e242ca5c02dd3bd5e6c6
Showing with 24 additions and 1 deletion.
  1. +20 −0 src/gui/qgspgquerybuilder.cpp
  2. +4 −1 src/gui/qgspgquerybuilder.h
@@ -53,6 +53,9 @@ QgsPgQueryBuilder::QgsPgQueryBuilder(QgsDataSourceURI *uri,
mOwnConnection = true; // we own this connection since we created it
// tell the DB that we want text encoded in UTF8
PQsetClientEncoding(mPgConnection, "UNICODE");
// and strip any quotation as this code does it's own quoting.
trimQuotation();

lblDataUri->setText(datasource);
populateFields();
}
@@ -85,6 +88,8 @@ QgsPgQueryBuilder::QgsPgQueryBuilder(QString tableName, PGconn *con,
mUri->schema = parts[0];
// strip whitespace to make sure the table name is clean
mUri->table = parts[1].stripWhiteSpace();
// and strip any quotation as this code does it's own quoting.
trimQuotation();

lblDataUri->setText(datasource);
populateFields();
@@ -153,6 +158,21 @@ void QgsPgQueryBuilder::populateFields()
PQclear(result);
}

void QgsPgQueryBuilder::trimQuotation()
{
// Trim " characters that may be surrounding the table and schema name
if (mUri->schema.at(0) == '"')
{
mUri->schema.remove(mUri->schema.length()-1, 1);
mUri->schema.remove(0, 1);
}
if (mUri->table.at(0) == '"')
{
mUri->table.remove(mUri->table.length()-1, 1);
mUri->table.remove(0, 1);
}
}

void QgsPgQueryBuilder::on_btnSampleValues_clicked()
{
QString sql = "SELECT DISTINCT \"" + lstFields->currentText() + "\" " +
@@ -119,7 +119,10 @@ class QgsPgQueryBuilder : public QDialog, private Ui::QgsPgQueryBuilderBase {
*/
void populateFields();


/*!
* Trims surround " characters from the schema and table name
*/
void trimQuotation();

/*! Get the number of records that would be returned by the current SQL
* @return Number of records or -1 if an error was encountered

0 comments on commit b0517be

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