Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-8217

QSqlRelationalTableModel should return records even if it cannot find the relations for it in the second/third.. tables

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P4: Low
    • 4.8.0
    • 3.x, 4.5.3
    • SQL Support
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            charles Charles Yin (closed Nokia identity) (Inactive)
            sanonymous Nokia Qt Support (Inactive)
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes