Skip to content
Permalink
Browse files

Fix for ticket #439 (yet more problems with fully quoted

schema.tables)
Also a better behaviour when the user clicks on 'sample' or 'all' in
the postgres query builder without a table selected.


git-svn-id: http://svn.osgeo.org/qgis/trunk@6238 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m
g_j_m committed Dec 11, 2006
1 parent b1b422d commit 85828f42220f0183be55dc2afd3b242734518216
Showing with 13 additions and 4 deletions.
  1. +13 −4 src/gui/qgspgquerybuilder.cpp
@@ -18,6 +18,7 @@
#include <QMessageBox>
#include "qgspgquerybuilder.h"
#include <qgslogger.h>
#include <QRegExp>
// default constructor
QgsPgQueryBuilder::QgsPgQueryBuilder(QWidget *parent, Qt::WFlags fl)
: QDialog(parent, fl)
@@ -82,12 +83,14 @@ QgsPgQueryBuilder::QgsPgQueryBuilder(QString tableName, PGconn *con,
.arg(PQdb(mPgConnection))
.arg(PQhost(mPgConnection))
.arg(PQuser(mPgConnection));

// populate minimum uri fields needed for the populate fields function
QStringList parts = QStringList::split(".", tableName); // table name contains table and schema
mUri->schema = parts[0];
QRegExp reg("\"(.+)\"\\.\"(.+)\"");
reg.indexIn(tableName);
QStringList parts = reg.capturedTexts(); // table name contains table and schema
mUri->schema = parts[1];
// strip whitespace to make sure the table name is clean
mUri->table = parts[1].stripWhiteSpace();
mUri->table = parts[2];

// and strip any quotation as this code does it's own quoting.
trimQuotation();

@@ -175,6 +178,9 @@ void QgsPgQueryBuilder::trimQuotation()

void QgsPgQueryBuilder::on_btnSampleValues_clicked()
{
if (lstFields->currentText().isEmpty())
return;

QString sql = "SELECT DISTINCT \"" + lstFields->currentText() + "\" " +
"FROM (SELECT \"" + lstFields->currentText() + "\" " +
"FROM \"" + mUri->schema + "\".\"" + mUri->table + "\" " +
@@ -214,6 +220,9 @@ void QgsPgQueryBuilder::on_btnSampleValues_clicked()

void QgsPgQueryBuilder::on_btnGetAllValues_clicked()
{
if (lstFields->currentText().isEmpty())
return;

QString sql = "select distinct \"" + lstFields->currentText()
+ "\" from \"" + mUri->schema + "\".\"" + mUri->table + "\" order by \"" + lstFields->currentText() + "\"";
// clear the values list

0 comments on commit 85828f4

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