From: APTX Date: Wed, 5 Sep 2012 17:55:48 +0000 (+0200) Subject: Not all queries can be prepared X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=5a8f9d2a8655b0b3ca91296025f3b0401a9e7dc9;p=localmylist.git Not all queries can be prepared --- diff --git a/localmylist/database.cpp b/localmylist/database.cpp index 5c739a8..60a7346 100644 --- a/localmylist/database.cpp +++ b/localmylist/database.cpp @@ -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 ¬ification) { return exec("NOTIFY " + notification);