Skip to content
Browse files
If an SQL insert fails during committing new features to the database,
include the offending sql in the error dialog box.

Also fix the remaining part of ticket #131 - the code wasn't coping
correctly with blank data fields.

git-svn-id: c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jul 25, 2006
1 parent fd39376 commit 986ea53
Showing 1 changed file with 14 additions and 1 deletion.
@@ -1695,6 +1695,8 @@ bool QgsPostgresProvider::addFeature(QgsFeature* f, int primaryKeyHighWater)
QString fieldvalue = it->fieldValue();
if (fieldvalue.isEmpty())
fieldvalue = "NULL";
bool charactertype=false;

@@ -1753,7 +1755,18 @@ bool QgsPostgresProvider::addFeature(QgsFeature* f, int primaryKeyHighWater)
ExecStatusType message=PQresultStatus(result);
QMessageBox::information(0,tr("INSERT error"),QString(PQresultErrorMessage(result)),QMessageBox::Ok);
// Use QgsMessage viewer here instead of a QMessageBox because
// we want to include the offending SQL, which may be quite
// long, and the QMessageBox doesn't wrap text, etc.

QString sqlDetails = PQresultErrorMessage(result);
sqlDetails += tr("The sql was:\n\n") + insert;
QgsMessageViewer viewer;
viewer.setWindowTitle(tr("SQL error"));

// QMessageBox::information(0,tr("INSERT error"), sqlDetails,QMessageBox::Ok);
return false;

0 comments on commit 986ea53

Please sign in to comment.