diff options
| author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2023-03-25 13:42:52 +0100 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-04-03 15:52:03 +0000 |
| commit | 2f709952cf6acdda83e42e587d744f81a05f2c03 (patch) | |
| tree | e07390486e34c27a76c52811c01fa2851f677627 /src | |
| parent | 07f7ed2badf0cc1972bf6ba15f4c0cde4a773f19 (diff) | |
QSqlError: also compare nativeErrorCode() in operator==() / operator!=()
A QSqlError is not equal when the native error code differs. The
database and driver text should not be considered during the
comparison because they might differ due to e.g. different locales.
[ChangeLog][QtSql][QSqlError] The comparison operators have been fixed to
take both error type and error code into account.
Change-Id: Ie7511f183f88dd454eb165c6ff237e51b79d1c08
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/sql/kernel/qsqlerror.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/sql/kernel/qsqlerror.cpp b/src/sql/kernel/qsqlerror.cpp index 1e093c236c3..7483a52e5c7 100644 --- a/src/sql/kernel/qsqlerror.cpp +++ b/src/sql/kernel/qsqlerror.cpp @@ -126,22 +126,26 @@ QSqlError &QSqlError::operator=(const QSqlError &other) } /*! - Compare the \a other error's values to this error and returns \c true, if it equal. + Compare the \a other error's type() and nativeErrorCode() + to this error and returns \c true, if it equal. */ bool QSqlError::operator==(const QSqlError &other) const { - return (d->errorType == other.d->errorType); + return (d->errorType == other.d->errorType && + d->errorCode == other.d->errorCode); } /*! - Compare the \a other error's values to this error and returns \c true if it is not equal. + Compare the \a other error's type() and nativeErrorCode() + to this error and returns \c true if it is not equal. */ bool QSqlError::operator!=(const QSqlError &other) const { - return (d->errorType != other.d->errorType); + return (d->errorType != other.d->errorType || + d->errorCode != other.d->errorCode); } |
