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

Changing copy of QSqlQuery changes original.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important 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), f744cef06 (dev), 97880102d (6.9)

      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
      

       

       

        For Gerrit Dashboard: QTBUG-91766
        # Subject Branch Project Status CR V

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

              Created:
              Updated:
              Resolved: