Skip to content

Commit f17d2de

Browse files
author
g_j_m
committedDec 11, 2006
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/qgis@6238 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed
 

‎src/gui/qgspgquerybuilder.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <QMessageBox>
1919
#include "qgspgquerybuilder.h"
2020
#include <qgslogger.h>
21+
#include <QRegExp>
2122
// default constructor
2223
QgsPgQueryBuilder::QgsPgQueryBuilder(QWidget *parent, Qt::WFlags fl)
2324
: QDialog(parent, fl)
@@ -82,12 +83,14 @@ QgsPgQueryBuilder::QgsPgQueryBuilder(QString tableName, PGconn *con,
8283
.arg(PQdb(mPgConnection))
8384
.arg(PQhost(mPgConnection))
8485
.arg(PQuser(mPgConnection));
85-
8686
// populate minimum uri fields needed for the populate fields function
87-
QStringList parts = QStringList::split(".", tableName); // table name contains table and schema
88-
mUri->schema = parts[0];
87+
QRegExp reg("\"(.+)\"\\.\"(.+)\"");
88+
reg.indexIn(tableName);
89+
QStringList parts = reg.capturedTexts(); // table name contains table and schema
90+
mUri->schema = parts[1];
8991
// strip whitespace to make sure the table name is clean
90-
mUri->table = parts[1].stripWhiteSpace();
92+
mUri->table = parts[2];
93+
9194
// and strip any quotation as this code does it's own quoting.
9295
trimQuotation();
9396

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

176179
void QgsPgQueryBuilder::on_btnSampleValues_clicked()
177180
{
181+
if (lstFields->currentText().isEmpty())
182+
return;
183+
178184
QString sql = "SELECT DISTINCT \"" + lstFields->currentText() + "\" " +
179185
"FROM (SELECT \"" + lstFields->currentText() + "\" " +
180186
"FROM \"" + mUri->schema + "\".\"" + mUri->table + "\" " +
@@ -214,6 +220,9 @@ void QgsPgQueryBuilder::on_btnSampleValues_clicked()
214220

215221
void QgsPgQueryBuilder::on_btnGetAllValues_clicked()
216222
{
223+
if (lstFields->currentText().isEmpty())
224+
return;
225+
217226
QString sql = "select distinct \"" + lstFields->currentText()
218227
+ "\" from \"" + mUri->schema + "\".\"" + mUri->table + "\" order by \"" + lstFields->currentText() + "\"";
219228
// clear the values list

0 commit comments

Comments
 (0)
Please sign in to comment.