From 5a8f9d2a8655b0b3ca91296025f3b0401a9e7dc9 Mon Sep 17 00:00:00 2001 From: APTX Date: Wed, 5 Sep 2012 19:55:48 +0200 Subject: [PATCH] Not all queries can be prepared --- localmylist/database.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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); -- 2.52.0