global transaction

This commit is contained in:
Aaron Seigo 2011-04-28 18:01:34 +02:00 committed by Marco Martin
parent 9d337a0c01
commit 1d550b15ea

View File

@ -136,14 +136,11 @@ void StorageJob::start()
valueGroup = "default"; valueGroup = "default";
} }
//kDebug() << operationName();
m_rdb->database()->transaction();
if (operationName() == "save") { if (operationName() == "save") {
QSqlQuery query(*m_rdb->database()); QSqlQuery query(*m_rdb->database());
if (!query.exec("BEGIN;")) {
setResult(false);
return;
}
if (params.value("key").toString().isNull()) { if (params.value("key").toString().isNull()) {
m_data.insert(params.value("key").toString(), params.value("data")); m_data.insert(params.value("key").toString(), params.value("data"));
} }
@ -210,7 +207,7 @@ void StorageJob::start()
query.bindValue(field, it.value()); query.bindValue(field, it.value());
if (!query.exec()) { if (!query.exec()) {
kDebug() << "query failed:" << query.lastQuery() << query.lastError().text(); //kDebug() << "query failed:" << query.lastQuery() << query.lastError().text();
setResult(false); setResult(false);
return; return;
} }
@ -218,7 +215,7 @@ void StorageJob::start()
query.bindValue(field, QVariant()); query.bindValue(field, QVariant());
} }
setResult(query.exec("COMMIT;")); setResult(true);
} else if (operationName() == "retrieve") { } else if (operationName() == "retrieve") {
QSqlQuery query(*m_rdb->database()); QSqlQuery query(*m_rdb->database());