From d6a01b3f82d626856001356c0875aa738a0346ac Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 4 Oct 2016 08:25:18 +0200 Subject: Support for subqueries. This allows us to match properties from a subquery. Unfortunately this also means that DataStoreQuery needs access to all type implementations to issue the subquery (for potentially another type). --- tests/querytest.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests') diff --git a/tests/querytest.cpp b/tests/querytest.cpp index afa8e33..6011a99 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -492,6 +492,42 @@ private slots: QCOMPARE(folders.size(), 1); } + void testSubquery() + { + // Setup + auto folder1 = Folder::createEntity("sink.dummy.instance1"); + folder1.setSpecialPurpose(QByteArrayList() << "purpose1"); + VERIFYEXEC(Sink::Store::create(folder1)); + + auto folder2 = Folder::createEntity("sink.dummy.instance1"); + folder2.setSpecialPurpose(QByteArrayList() << "purpose2"); + VERIFYEXEC(Sink::Store::create(folder2)); + + { + auto mail = Mail::createEntity("sink.dummy.instance1"); + mail.setUid("mail1"); + mail.setFolder(folder1); + VERIFYEXEC(Sink::Store::create(mail)); + } + { + auto mail = Mail::createEntity("sink.dummy.instance1"); + mail.setUid("mail2"); + mail.setFolder(folder2); + VERIFYEXEC(Sink::Store::create(mail)); + } + + // Ensure all local data is processed + Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1").exec().waitForFinished(); + + //Setup two folders with a mail each, ensure we only get the mail from the folder that matches the folder filter. + Query query; + query.filter(Sink::Query().containsFilter("purpose1")); + query.request(); + + auto mails = Sink::Store::read(query); + QCOMPARE(mails.size(), 1); + QCOMPARE(mails.first().getUid().toLatin1(), QByteArray("mail1")); + } }; QTEST_MAIN(QueryTest) -- cgit v1.2.3