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

QSqlTableModel gets confused by records with identical content

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 4.8.6, 5.7.0
    • SQL Support
    • Linux
      Windows

    Description

      If a table contains two or more records with the same data in all fields (but different ROWIDs), performing an edit or delete on one of them will affect all of them.

      You can reproduce the problem with sqliteman from https://github.com/rparkins999/sqliteman.git. Clone this version and build with Qt 4.8.6 on Linux. You may have to set DWANT_INTERNAL_SQLDRIVER=0 in the cmake command, as I have had problems building it with the Qt internal driver. Run the resulting sqliteman and insert the following sql statements into the sql editing window:

      create table test_table (col1, col2) ;
      insert into test_table values (1, 2);
      insert into test_table values (1, 2);
      insert into test_table values (3, 4);
      select rowid, col1, col2 from test_table ;

      Execute them one at a time (using the single green arrow icon above).
      After the select you will see a table that looks like this:-

      rowid col1 col2
      1 1 2
      2 1 2
      3 3 4

      The first two rows have identical data but different rowids.

      Now open the table by expanding the Tables list and clicking on test_table. You will see an editable version of the table which is the same but without the rowids. Delete either of the first two rows, or edit a field in one of them, and then click the Commit button. The change affects both rows! If you edit or delete using an sql statement referring to the rowid in the sql editing window, only one row is affected.

      Attachments

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

        Activity

          People

            mabrand Mark Brand
            rparkins Richard Parkins
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes