Reset SQL results table when the query has not returned data

When we know that the just executed query has not returned data, reset the
table results model, so the results view is also reset.

Added QAbstractItemModel::beginResetModel() and
QAbstractItemModel::endResetModel() to the model's reset method. This
resets completely the table view.

This improves the situation for #1431, without addressing the underlying
problem of not detecting correctly the type of query. In any case, any
query not returning data should reset the results from previous queries.
This commit is contained in:
mgrojo
2018-06-19 18:35:11 +02:00
committed by Martin Kleusberg
parent 614068a57a
commit 01f0146bbe
2 changed files with 5 additions and 0 deletions

View File

@@ -1188,6 +1188,8 @@ void MainWindow::executeQuery()
// If we get here, the SQL statement doesn't return data and just executes. Don't run it again because it has already been executed.
// But do set the modified flag because statements that don't return data, often modify the database.
sqlWidget->getModel()->reset();
QString stmtHasChangedDatabase;
if(query_part_type == InsertStatement || query_part_type == UpdateStatement || query_part_type == DeleteStatement)
stmtHasChangedDatabase = tr(", %1 rows affected").arg(sqlite3_changes(pDb.get()));