Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.3.2
-
None
-
34472e946a11bf6e06ba9ed7b72f938ea6eede02
Description
I'm using a MySql DB with some QSqlRelationalTableModel models. All my tables use 'id' name as primary key, and there are some relational tables. All worked fine in Qt 4.8 until I migrated the program to Qt 5.3.2, whe I realized that insertRecord() function returns 'false' in many cases. After investigating this issue, I have concluded the problem is because of QSqlTableModel::selectRow() function.
I think this is because the internal SQL query made in this function is wrong when the key and the foreign key use the same name, like in the following example:
CREATE TABLE cw_building_typology { id smallint unsigned not null auto_increment, name varchar(125) null default 'Undefined', PRIMARY KEY(id) } ENGINE=InnoDB CREATE TABLE cw_building { id int unsigned not null auto_increment, b_type smallint unsigned not null default 1, address text null default null, remarks text null default null, PRIMARY KEY(id), KEY b_type (b_type), FOREIGN KEY (b_type) REFERENCES cw_building_typology (id) ON DELETE RESTRICT ON UPDATE CASCADE } ENGINE=InnoDB
In Qt4 all works fine, but in Qt5 I must change the primary key name in the second table.
Thanks in advance.
Attachments
Issue Links
- is duplicated by
-
QTBUG-50069 QSqlRelationalTableModel provides incorrect display data after editing a foreign cell
- Closed