Commit 01cf5be6 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

CollectionsStatistics: make sure that flags used in queries exist

The pre-fetched cache might otherwise be broken on a newly
set up database.
parent 505c6fd1
......@@ -195,7 +195,7 @@ QueryBuilder CollectionStatistics::prepareGenericQuery()
Query::Condition seenCondition(Query::And);
seenCondition.addColumnCondition(PimItem::idFullColumnName(), Query::Equals, FLAGS_COLUMN(SeenFlags, leftColumn));
seenCondition.addValueCondition(FLAGS_COLUMN(SeenFlags, rightColumn), Query::Equals,
Flag::retrieveByName(QStringLiteral(AKONADI_FLAG_SEEN)).id());
Flag::retrieveByNameOrCreate(QStringLiteral(AKONADI_FLAG_SEEN)).id());
qb.addJoin(QueryBuilder::LeftJoin,
QStringLiteral("%1 AS %2").arg(PimItemFlagRelation::tableName(), SeenFlagsTableName),
seenCondition);
......@@ -204,7 +204,7 @@ QueryBuilder CollectionStatistics::prepareGenericQuery()
Query::Condition ignoredCondition(Query::And);
ignoredCondition.addColumnCondition(PimItem::idFullColumnName(), Query::Equals, FLAGS_COLUMN(IgnoredFlags, leftColumn));
ignoredCondition.addValueCondition(FLAGS_COLUMN(IgnoredFlags, rightColumn), Query::Equals,
Flag::retrieveByName(QStringLiteral(AKONADI_FLAG_IGNORED)).id());
Flag::retrieveByNameOrCreate(QStringLiteral(AKONADI_FLAG_IGNORED)).id());
qb.addJoin(QueryBuilder::LeftJoin,
QStringLiteral("%1 AS %2").arg(PimItemFlagRelation::tableName(), IgnoredFlagsTableName),
ignoredCondition);
......
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