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

Changing copy of QSqlQuery changes original.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.6.0, 5.15.2
    • Fix Version/s: 6.2.0 Alpha
    • Component/s: SQL Support
    • Labels:
      None
    • Platform/s:
      All
    • Commits:
      14f9f00fdb2dc428610c08e3d9d03e38e9602166 (qt/qtbase/dev)

      Description

      When I copy prepared QSqlQuery with assign or copy constructor and bind to them different values with bindValue they both will have the same bound value, one which was bound last.

       

      QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "test");
      db.setDatabaseName(":memory:");
      db.open();
      QSqlQuery createQuery(db);
      createQuery.exec("CREATE TABLE if not exists test"
                                           "(test_id integer)");
      
      QSqlQuery query1(db);
      query1.prepare("INSERT INTO test (test_id) VALUES(:test_id)");
      query1.bindValue(":test_id", 1); //this returns 1
      qDebug() << query1.boundValue(":test_id");
      QSqlQuery query2(query1); //QSqlQuery query2 = query1;
      query2.bindValue(":test_id", 2);
      qDebug() << query1.boundValue(":test_id") << query2.boundValue(":test_id"); //both return 2
      

       

       

        Attachments

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

          Activity

            People

            Assignee:
            peppe Giuseppe D'Angelo
            Reporter:
            skogach Oleg Oleg
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes