summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2012-06-11 12:30:23 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-11 14:24:49 +0200
commitb80efec0b680d925efc30174b6721c0db0d8c741 (patch)
treebd46371a268e54b168b0105a1f61b4902e9f9def
parentdb5a44785e398fe3fee884316d39dca0f1be35ad (diff)
Fixed subscription to a notification without explicitly specifying _type
If the don't know the _type we cannot figure out the object table the object is stored in, so for now lets assume it is the main object table. This will still be broken if the assumption is wrong and the query like [?_uuid="{123}"] is actually against a view object, but this should be fixed in one of the next patches where we remove the concept of object tables and store all objects in one main object table. Change-Id: Icc259cc857b691acca3f316d7dea29244616ffe3 Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
-rw-r--r--src/partition/jsondbpartition.cpp4
-rw-r--r--tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp32
2 files changed, 35 insertions, 1 deletions
diff --git a/src/partition/jsondbpartition.cpp b/src/partition/jsondbpartition.cpp
index 437a7d3..170873a 100644
--- a/src/partition/jsondbpartition.cpp
+++ b/src/partition/jsondbpartition.cpp
@@ -403,7 +403,6 @@ void JsonDbPartitionPrivate::_q_objectsUpdated(bool viewUpdated, const JsonDbUpd
notificationKeys << object.value(JsonDbString::kUuidStr).toString();
notificationKeys << QStringLiteral("__generic_notification__");
- QHash<QString, JsonDbObject> objectCache;
for (int i = 0; i < notificationKeys.size(); i++) {
QString key = notificationKeys[i];
for (QMultiHash<QString, QPointer<JsonDbNotification> >::const_iterator it = mKeyedNotifications.find(key);
@@ -779,6 +778,9 @@ void JsonDbPartition::addNotification(JsonDbNotification *notification)
}
notification->setObjectTable(objectTable);
+ } else {
+ // assume it is the main object table :(
+ notification->setObjectTable(d->mObjectTable);
}
bool generic = true;
diff --git a/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp b/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp
index cb465cc..44e6e24 100644
--- a/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp
+++ b/tests/auto/qjsondbwatcher/testqjsondbwatcher.cpp
@@ -95,6 +95,7 @@ private slots:
void privatePartition();
void addAndRemove();
void removeWatcherStatus();
+ void uuidQuery();
};
TestQJsonDbWatcher::TestQJsonDbWatcher()
@@ -968,6 +969,37 @@ void TestQJsonDbWatcher::removeWatcherStatus()
}
}
+void TestQJsonDbWatcher::uuidQuery()
+{
+ QUuid uuid = QUuid::createUuid();
+ QJsonDbWatcher watcher;
+ watcher.setQuery(QStringLiteral("[?_uuid=%uuid]"));
+ watcher.bindValue(QStringLiteral("uuid"), uuid.toString());
+ QVERIFY(mConnection->addWatcher(&watcher));
+ QVERIFY(waitForStatus(&watcher, QJsonDbWatcher::Active));
+
+ // create the object
+ QJsonObject object;
+ object.insert(QLatin1String("_uuid"), uuid.toString());
+ object.insert(QLatin1String("_type"), QLatin1String("uuidQuery"));
+ QJsonDbWriteRequest request;
+ request.setObject(object);
+ QVERIFY(mConnection->send(&request));
+ QVERIFY(waitForResponseAndNotifications(&request, &watcher, 1));
+ QList<QJsonObject> results = request.takeResults();
+ QCOMPARE(results.size(), 1);
+ object.insert(QLatin1String("_version"), results.at(0).value(QLatin1String("_version")));
+
+ // update the object
+ object.insert(QLatin1String("foo"), QLatin1String("bar"));
+ request.setObject(object);
+ QVERIFY(mConnection->send(&request));
+ QVERIFY(waitForResponseAndNotifications(&request, &watcher, 1));
+
+ QVERIFY(mConnection->removeWatcher(&watcher));
+ QVERIFY(waitForStatus(&watcher, QJsonDbWatcher::Inactive));
+}
+
QTEST_MAIN(TestQJsonDbWatcher)
#include "testqjsondbwatcher.moc"