Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 2a978d36 authored by Ivan Čukić's avatar Ivan Čukić 👁

Separating queries for removing from a specific activity and from all activities

parent 392aa532
......@@ -144,26 +144,32 @@ void ResourceLinking::UnlinkResourceFromActivity(QString initiatingAgent,
"ResourceLinking::UnlinkResourceFromActivity",
"Resource shoud not be empty");
Utils::prepare(resourcesDatabase(), unlinkResourceFromActivityQuery,
usedActivity == ":any" ?
QSqlQuery *query = nullptr;
if (usedActivity == ":any") {
Utils::prepare(resourcesDatabase(), unlinkResourceFromAllActivitiesQuery,
QStringLiteral(
"DELETE FROM ResourceLink "
"WHERE "
"initiatingAgent = COALESCE(:initiatingAgent , '') AND "
"targettedResource = COALESCE(:targettedResource, '') "
) :
));
query = unlinkResourceFromAllActivitiesQuery.get();
} else {
Utils::prepare(resourcesDatabase(), unlinkResourceFromActivityQuery,
QStringLiteral(
"DELETE FROM ResourceLink "
"WHERE "
"usedActivity = COALESCE(:usedActivity , '') AND "
"initiatingAgent = COALESCE(:initiatingAgent , '') AND "
"targettedResource = COALESCE(:targettedResource, '') "
)
);
));
query = unlinkResourceFromActivityQuery.get();
}
DATABASE_TRANSACTION(resourcesDatabase());
Utils::exec(Utils::FailOnError, *unlinkResourceFromActivityQuery,
Utils::exec(Utils::FailOnError, *query,
":usedActivity" , usedActivity,
":initiatingAgent" , initiatingAgent,
":targettedResource" , targettedResource
......
......@@ -89,6 +89,7 @@ private:
QString currentActivity() const;
std::unique_ptr<QSqlQuery> linkResourceToActivityQuery;
std::unique_ptr<QSqlQuery> unlinkResourceFromAllActivitiesQuery;
std::unique_ptr<QSqlQuery> unlinkResourceFromActivityQuery;
std::unique_ptr<QSqlQuery> isResourceLinkedToActivityQuery;
};
......
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