Skip to content

Commit

Permalink
Reduce the time taken to populate the sample list. Technique to do this
Browse files Browse the repository at this point in the history
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
  • Loading branch information
g_j_m committed Oct 29, 2006
1 parent b4ad7b5 commit d573aaa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gui/qgspgquerybuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ void QgsPgQueryBuilder::populateFields()

void QgsPgQueryBuilder::on_btnSampleValues_clicked()
{
QString sql = "select distinct \"" + lstFields->currentText()
+ "\" from \"" + mUri->schema + "\".\"" + mUri->table + "\" order by \"" + lstFields->currentText()
+ "\" limit 25";
QString sql = "SELECT DISTINCT \"" + lstFields->currentText() + "\" " +
"FROM (SELECT \"" + lstFields->currentText() + "\" " +
"FROM \"" + mUri->schema + "\".\"" + mUri->table + "\" " +
"LIMIT 5000) AS foo " +
"ORDER BY \"" + lstFields->currentText() + "\" "+
"LIMIT 25";
// clear the values list
lstValues->clear();
// determine the field type
Expand All @@ -183,7 +186,7 @@ void QgsPgQueryBuilder::on_btnSampleValues_clicked()

}else
{
QMessageBox::warning(this, tr("Database error"), tr("Failed to get sample of field values") + QString(PQerrorMessage(mPgConnection)) );
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>");
}
// free the result set
PQclear(result);
Expand Down

0 comments on commit d573aaa

Please sign in to comment.