summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Simons <kevin.simons@nokia.com>2012-03-20 12:35:20 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-20 14:49:03 +0100
commitb4f2193e1cec3dbcaba3a82727a2aaedec66ee28 (patch)
treef3c937acc06e614d2d909dab86ef68c1d869df42
parentd88ce96d7875744d6f265c6d4ba3208799b3786b (diff)
Objects which stop matching a watcher query should not have _deleted : true
When an object stops matching a watcher query, we send a notification that the object has been "removed". However, it shouldn't contain the _deleted property or else applications will believe the object has actually been removed from the database. Change-Id: I160fedf503d76d89baa0511b6cf6c6be030be19b Reviewed-by: Jing Bai <jing.t.bai@nokia.com>
-rw-r--r--src/daemon/dbserver.cpp3
-rw-r--r--tests/auto/client/test-jsondb-client.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/daemon/dbserver.cpp b/src/daemon/dbserver.cpp
index d7cc336..f929ef0 100644
--- a/src/daemon/dbserver.cpp
+++ b/src/daemon/dbserver.cpp
@@ -498,7 +498,8 @@ void DBServer::objectUpdated(const QString &partitionName, quint32 stateNumber,
effectiveAction = JsonDbNotification::Create;
} else if (oldMatches && (!newMatches || object.isDeleted())) {
r = oldObject;
- r.insert(JsonDbString::kDeletedStr, true);
+ if (object.isDeleted())
+ r.insert(JsonDbString::kDeletedStr, true);
effectiveAction = JsonDbNotification::Delete;
} else if (oldMatches && newMatches) {
effectiveAction = JsonDbNotification::Update;
diff --git a/tests/auto/client/test-jsondb-client.cpp b/tests/auto/client/test-jsondb-client.cpp
index 40946c4..b316f53 100644
--- a/tests/auto/client/test-jsondb-client.cpp
+++ b/tests/auto/client/test-jsondb-client.cpp
@@ -908,6 +908,7 @@ void TestJsonDbClient::notifyUpdate()
// Update the notify-test object
// query no longer matches, so we should receive a "remove" notification even though it is an update
+ // this means it should not contain the _deleted property
object.insert("_uuid",uuid);
object.insert("_version", version);
object.insert("filter","nomatch");
@@ -918,6 +919,7 @@ void TestJsonDbClient::notifyUpdate()
n = mNotifications.takeFirst();
QCOMPARE(n.mNotifyUuid, notifyUuid);
QCOMPARE(n.mAction, QLatin1String("remove"));
+ QVERIFY(!n.mObject.toMap().contains(JsonDbString::kDeletedStr));
// Remove the notify-test object
id = mClient->remove(object);