]> Some of my projects - localmylist.git/commitdiff
Not all queries can be prepared
authorAPTX <marek321@gmail.com>
Wed, 5 Sep 2012 17:55:48 +0000 (19:55 +0200)
committerAPTX <marek321@gmail.com>
Wed, 5 Sep 2012 17:55:48 +0000 (19:55 +0200)
localmylist/database.cpp

index 5c739a80451d2b1ef25cf40aad9c547e614ad0b0..60a7346c24393ea1c2f7ab7a9688db7a76b83a07 100644 (file)
@@ -1601,9 +1601,19 @@ bool Database::exec(const QString &sql)
 {
        Q_ASSERT_X(d->thread == QThread::currentThread(), "threads", "DB used from different thread");
 
-       QSqlQuery query = prepareOneShot(sql);
+       if (!d->db.isOpen())
+       {
+               disconnect();
+               if (!connect())
+                       return false;
+       }
+
+       QSqlQuery query = QSqlQuery(d->db);
+
+       if (!query.exec(sql))
+               return checkError(query);
 
-       return exec(query);
+       return true;
 }
 
 bool Database::checkError(QSqlQuery &query, bool prepared)
@@ -1651,6 +1661,7 @@ bool Database::retryExec(QSqlQuery &query, bool prepared)
        return false;
 }
 
+
 bool Database::notify(const QString &notification)
 {
        return exec("NOTIFY " + notification);