[Qt-interest] QSqlTableModel Modify row error?

Israel Brewster israel at frontierflying.com
Fri Jul 10 22:31:58 CEST 2009


I am running into some difficulty using QSqlTableModel when a sql  
record contains null values. Specifically, changes made to the record  
are not saved to the database. I have attached a basic test case,  
using QTest, that illustrates the issue. The problem occurs in the  
following situation:

1) A SQL record is created and saved to a database containing one or  
more NULL columns - in the test case attached, there are three columns  
in the database, and only the first one is populated.
2) A QSqlTableModel is set up that retrieves said record
3) The record containing NULL values is modified in the  
QSqlTableModel, and the changes (supposedly) saved back to the database
4) upon next query, we see that the record has not been changed.

On my build machine, running Mac OS X 10.5, Qt 4.5.2, the test case  
fails on the submitAll with a "Parameter count mismatch" On a friends  
machine (Ubuntu Linux 9.04, Qt 4.5.0, pkg version 4.5.0-0ubuntu4.1)  
the submitAll() command works (at least it returns true), but when the  
database is re-queried, the modifications are not there. Either way,  
it appears to be broken. Am I missing something in my code, or is this  
a bug with QSqlTableModel? I wrote about this earlier, but didn't have  
as straight-forward a test case written then. Thanks.

-----------------------------------------------
Israel Brewster
Computer Support Technician II
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Israel Brewster.vcf
Type: text/directory
Size: 397 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090710/764d6275/attachment.bin 
-------------- next part --------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestSQL.pro
Type: application/octet-stream
Size: 292 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090710/764d6275/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testclass.cpp
Type: application/octet-stream
Size: 4750 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090710/764d6275/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testclass.h
Type: application/octet-stream
Size: 325 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090710/764d6275/attachment-0002.obj 


More information about the Qt-interest-old mailing list