Details
-
Suggestion
-
Resolution: Done
-
P4: Low
-
3.x, 4.5.3
-
c4280dbd9bb37cca21d007f5f8b9217f80b44043 e2e62bc810d21fecc9ed1d1db486b529b760d292
Description
Currently we use WHERE condition in QSqlRelationalTableModel to filter the records without relations. However this doesn't conform to the general idea.
The records of the main table should always be returned even if there is not relation found. The main fields should be filled in, and relational fields should be empty in this case.
This problem can be reproduced using examples/sql/relationaltablemodel/. Change relationaltablemodel.cpp, around line 90:
query.exec("insert into city values(100, 'San Jose')"); //change 100 to 101
Because internally Qt uses the following sql command to query the data:
"SELECT employee."id", employee."name", relTblAl_2.name
AS city_name_3, relTblAl_3.name AS country_name_2
FROM employee, city relTblAl_2, country relTblAl_3
WHERE (employee."city" = relTblAl_2.id AND employee."country" = relTblAl_3.id) "
The WHERE condition causes the records without relations are not returned to the view.