Commit 42397246 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Workaround a weird misbehaviour of SQLite when checking tag RID

For some reason "WHERE remoteId = 'rid-with-hyphen'" would not match
any rows even if such row exists in TagRemoteIdResourceRelation. This
only seems to affect a specific case in Zanshin's akonadistoragetest.
I couldn't reproduce this on a clean SQLite database nor could  I
reproduce it with manually created entries in the test's instance DB,
but I could confirm that with data created by the test itself.

For now the problem is worked-around by using "LIKE" instead of "=",
which matches the strings correctly.
parent ad6695fa
......@@ -337,7 +337,13 @@ Tag::List HandlerHelper::resolveTagsByRID(const QStringList &tagsRIDs, CommandCo
cond.addColumnCondition(Tag::idFullColumnName(), Query::Equals, TagRemoteIdResourceRelation::tagIdFullColumnName());
cond.addValueCondition(TagRemoteIdResourceRelation::resourceIdFullColumnName(), Query::Equals, context->resource().id());
qb.addJoin(QueryBuilder::LeftJoin, TagRemoteIdResourceRelation::tableName(), cond);
qb.addValueCondition(TagRemoteIdResourceRelation::remoteIdFullColumnName(), Query::Equals, tagRID);
if (DbType::type(DataStore::self()->database()) == DbType::Sqlite) {
// FIXME: Workaround for an SQLite issue where "WHERE remoteId = 'rid-with-hyphen'" does
// not match any rows, even if such row exists. This only seems to affect this table
qb.addValueCondition(TagRemoteIdResourceRelation::remoteIdFullColumnName(), Query::Like, tagRID);
} else {
qb.addValueCondition(TagRemoteIdResourceRelation::remoteIdFullColumnName(), Query::Equals, tagRID);
if (!qb.exec()) {
throw HandlerException("Unable to resolve tags");
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment