Can't save data with customised SQLRelationalTableModel
-
I've created a subclass of SQLRelationalTableModel and overridden selectStatement(). This is so that I can modify the select statement to convert integers to dates (I'm using SQLite).
This works fine, and it appears that I can update the view (QTableView) correctly
Unfortunately when I call submitAll() on my model I get the error "no such column: startDate) Unable to execute statement".
The column in question is "employee.startDate". How can I see the SQL statement that will be used to update my database? And how can I then modify it if necessary?
-
Jonathan: this is what I tried to warn you about on your "original thread":http://developer.qt.nokia.com/forums/viewthread/2862/.
You may want to look into the source for the QSQLRelationTableModel to see how it works. I assume it can get the column name if you a query or may have issues dealing with different data types.
-
[quote author="Jonathan" date="1294216603"]Thanks fcrochik, you've highlighted my mistake. Originally I just replaced "startDate" with "date(employee."startDate")".
Replacing it with “date(employee.”startDate”) as startDate” cures the problem.[/quote]
You are welcome. Glad to hear that it worked.