Skip to content

Commit 5500bdc

Browse files
israelins85The Qt Project
authored and
The Qt Project
committed
ODBC: fixed consistence of return of QODBCResult::exec()
The QODBCResult::exec() returns false when query is an delete with no data do delete caused by SQLExecute function returning SQL_NO_DATA, but the false return means error on execution. Task-number: QTBUG-10569 Change-Id: I6c7ebadcf62ab404b60c7bcccdab6a10bf16a923 Reviewed-by: Mark Brand <[email protected]> (cherry-picked from qtbase commit 0646d1131b4bc65cdd9af29f4ce00fdd2398a3df) Reviewed-by: Andy Shaw <[email protected]>
1 parent dd22022 commit 5500bdc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/sql/drivers/odbc/qsql_odbc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ bool QODBCResult::exec()
15981598
}
15991599
}
16001600
r = SQLExecute(d->hStmt);
1601-
if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1601+
if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r != SQL_NO_DATA) {
16021602
qWarning() << "QODBCResult::exec: Unable to execute statement:" << qODBCWarn(d);
16031603
setLastError(qMakeError(QCoreApplication::translate("QODBCResult",
16041604
"Unable to execute statement"), QSqlError::StatementError, d));

tests/auto/qsqlquery/tst_qsqlquery.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,10 @@ void tst_QSqlQuery::isActive()
10301030
QVERIFY_SQL( q, exec( "delete from " + qtest + " where id = 42" ) );
10311031

10321032
QVERIFY( q.isActive() );
1033+
1034+
QVERIFY_SQL( q, exec( "delete from " + qtest + " where id = 42" ) );
1035+
1036+
QVERIFY( q.isActive() );
10331037
}
10341038

10351039
void tst_QSqlQuery::numRowsAffected()

0 commit comments

Comments
 (0)