Skip to content

Commit

Permalink
QSqlError: Set error code for psql-driver.
Browse files Browse the repository at this point in the history
Task-number: QTBUG-142
Change-Id: I4a68da595b7c8869188225958eaa88f789d4c3bf
Reviewed-by: Mark Brand <[email protected]>
  • Loading branch information
Marcel Krems authored and The Qt Project committed Dec 20, 2013
1 parent 1063161 commit 14170bb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/sql/drivers/psql/qsql_psql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type,
{
const char *s = PQerrorMessage(p->connection);
QString msg = p->isUtf8 ? QString::fromUtf8(s) : QString::fromLocal8Bit(s);
QString errorCode;
if (result) {
const char *sCode = PQresultErrorField(result, PG_DIAG_SQLSTATE);
msg += QString::fromLatin1("(%1)").arg(QString::fromLatin1(sCode));
errorCode = QString::fromLatin1(PQresultErrorField(result, PG_DIAG_SQLSTATE));
msg += QString::fromLatin1("(%1)").arg(errorCode);
}
return QSqlError(QLatin1String("QPSQL: ") + err, msg, type);
return QSqlError(QLatin1String("QPSQL: ") + err, msg, type, errorCode);
}

bool QPSQLResultPrivate::processResults()
Expand Down

0 comments on commit 14170bb

Please sign in to comment.