QSqlRelationalTableModel removeRows or deleteRowFromTable?
-
Hi
I'm currently developing an application that will be talking to a database of over 300 tables.
All the tables share a common set of columns one of which holds whether the row is deleted or not. Yes DELETE FROM isn't called, its historic and I don't plan on changing it.
If I create a class derived from QSqlRelationTableModel or QSqlTableModel, which of removeRows or deleteRowFromTable am I best implementing such that an UPDATE SET happens instead of the delete?
-
@Snowman said in QSqlRelationalTableModel removeRows or deleteRowFromTable?:
which of removeRows or deleteRowFromTable am I best implementing such that an UPDATE SET happens instead of the delete?
removeRow(s)
will calldeleteRowFromTable
at the end. -
@Snowman
As @Pl45m4 has said,deleteRowFromTable()
is the low-level method which does the deletion.I don't know whether you will have problems. Qt assumes deleting a row will delete it from the database. There must be more to your code than your "update column for deletion instead". For example, your normal "populate table"
SELECT
command must be something likeSELECT from table WHERE deletion_column <> true
or similar? What would happen if you try to re-add a row where it already exists but has its deletion flag set --- Qt will expect to do anINSERT
, you will need an un-UPDATE
.Not saying you can't do it, just I don't know how well it will play with Qt's
QSqlTableModel
assumptions.....