Description of problem: This bug is causing the failure in LSB test suite Message from the test: Target interface(s): QSqlTableModel::deleteRowFromTable(int) -------- CONSTRAINT FOR RETURN FAILED: '($0 == true)' Requirement failed: {deleteRowFromTable.02} <<< REQ NOT FOUND >>> The failure is tracked in LSB bug http://bugs.linuxbase.org/show_bug.cgi?id=2782 This indeed seems to be a bug in Qt as I am able to reproduce this failure on Qt 4.8.4. The testcase works correctly when compiled and executed against Qt 5 (current git master), I was however unable to determine the specific commit that fixes this behavior. Quick debug shows, that QSqlTableModel fails to find primary key in cache, so the "WHERE" part of the DELETE statement cannot be created and thus the operation is aborted. Version-Release number of selected component (if applicable): qt-4.8.4-14.fc18.x86_64 How reproducible: always Steps to Reproduce: compile & execute the attached reproducer # g++ test.cpp -I/usr/include -lQtCore -lQtGui -lQtSql # ./a.out ASSERT: "Return == true" in file test.cpp, line 85 Aborted (core dumped) Actual results: abort Expected results: no abort
Created attachment 736788 [details] standalone reproducer
deleteRowFromTable() is not intended to be used this way. The documentation says: This is a low-level method that operates directly on the database and should not be called directly. Use removeRow() or removeRows() to delete values. The model will decide depending on its edit strategy when to modify the database. Returns true if the row was deleted; otherwise returns false. See also removeRow() and removeRows(). i attached the patch for the test.cpp, it makes test.cpp working correctly --- test.cpp.orig 2013-04-16 17:27:06.000000000 +0200 +++ test.cpp 2013-05-22 10:37:06.876812816 +0200 @@ -44,7 +44,7 @@ bool QSqlTableModelChild::deleteRowFromTable_Adv(int Par_1) { - return this->deleteRowFromTable(Par_1); + return this->removeRow(Par_1); } #define PAR_0 0 @@ -82,7 +82,7 @@ "CONSTRAINT FOR RETURN FAILED: '($0 == true)'", (Return == true)); */ - Q_ASSERT(Return == true); + Q_ASSERT(Return == false); //CHECK OBJECT VALUE /*