Skip to content

Commit d573aaa

Browse files
author
g_j_m
committedOct 29, 2006
Reduce the time taken to populate the sample list. Technique to do this
suggested in ticket #364. Improve the error message in the dialog if the sample query fails git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6032 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed
 

‎src/gui/qgspgquerybuilder.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ void QgsPgQueryBuilder::populateFields()
155155

156156
void QgsPgQueryBuilder::on_btnSampleValues_clicked()
157157
{
158-
QString sql = "select distinct \"" + lstFields->currentText()
159-
+ "\" from \"" + mUri->schema + "\".\"" + mUri->table + "\" order by \"" + lstFields->currentText()
160-
+ "\" limit 25";
158+
QString sql = "SELECT DISTINCT \"" + lstFields->currentText() + "\" " +
159+
"FROM (SELECT \"" + lstFields->currentText() + "\" " +
160+
"FROM \"" + mUri->schema + "\".\"" + mUri->table + "\" " +
161+
"LIMIT 5000) AS foo " +
162+
"ORDER BY \"" + lstFields->currentText() + "\" "+
163+
"LIMIT 25";
161164
// clear the values list
162165
lstValues->clear();
163166
// determine the field type
@@ -183,7 +186,7 @@ void QgsPgQueryBuilder::on_btnSampleValues_clicked()
183186

184187
}else
185188
{
186-
QMessageBox::warning(this, tr("Database error"), tr("Failed to get sample of field values") + QString(PQerrorMessage(mPgConnection)) );
189+
QMessageBox::warning(this, tr("Database error"), tr("<p>Failed to get sample of field values using SQL:</p><p>") + sql + "</p><p>Error message was: "+ QString(PQerrorMessage(mPgConnection)) + "</p>");
187190
}
188191
// free the result set
189192
PQclear(result);

0 commit comments

Comments
 (0)
Please sign in to comment.