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

execBatch does not work if database does not support it

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.4.2
    • SQL Support
    • None
    • linux, custom build qt 5.4.2 from the source package

      when doing an QSqlQuery::execBatch() on a database which does not support a batch exec, it does not work like expected. The documentation tells me that it will fall back into single row insertion. My understanding would be that the result should be the same, like with a database that supports batch insert.

      Reproduction is easy simply remove the following two lines from the file qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp in method tst_QSqlQuery::batchExec() :

          if ( !db.driver()->hasFeature( QSqlDriver::BatchOperations ) )
              QSKIP( "Database can't do BatchOperations");
      

      the test then gives me the the following output:

      $ ./tst_qsqlquery batchExec
      ********* Start testing of tst_QSqlQuery *********
      Config: Using QtTest library 5.4.2, Qt 5.4.2 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 4.8.4)
      QDEBUG : tst_QSqlQuery::initTestCase() Opening: "0_QSQLITE@/tmp/tst_qsqlquery-mhpCP7/foo.db"
      PASS   : tst_QSqlQuery::initTestCase()
      FAIL!  : tst_QSqlQuery::batchExec(0_QSQLITE@/tmp/tst_qsqlquery-mhpCP7/foo.db) Compared values are not the same
         Actual   (q.value( 0 ).toInt()): 0
         Expected (1)                   : 1
         Loc: [tst_qsqlquery.cpp(2175)]
      PASS   : tst_QSqlQuery::cleanupTestCase()
      Totals: 2 passed, 1 failed, 0 skipped, 0 blacklisted
      ********* Finished testing of tst_QSqlQuery *********
      

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

            mabrand Mark Brand
            cmon Simon Schäfer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes