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

Changing copy of QSqlQuery changes original.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.2.0 Alpha
    • 5.6.0, 5.15.2
    • SQL Support
    • None
    • All
    • 14f9f00fdb2dc428610c08e3d9d03e38e9602166 (qt/qtbase/dev), 7ba2cb99a (dev), f0bc9c6f4 (6.5)

    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

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There is 1 open Gerrit change