Added unit tests on orphaned entries

This commit is contained in:
emeric
2019-05-16 13:49:56 +02:00
parent 41c317d3ff
commit febfe518ba
4 changed files with 111 additions and 30 deletions
+8
View File
@@ -51,6 +51,14 @@ Cluster::getAll(Wt::Dbo::Session& session)
return std::vector<Cluster::pointer>(res.begin(), res.end());
}
std::vector<Cluster::pointer>
Cluster::getAllOrphans(Wt::Dbo::Session& session)
{
Wt::Dbo::collection<Cluster::pointer> res {session.query<Cluster::pointer>("SELECT DISTINCT c FROM cluster c WHERE NOT EXISTS(SELECT 1 FROM track t INNER JOIN track_cluster t_c ON t.id = t_c.track_id)")};
return std::vector<Cluster::pointer>(res.begin(), res.end());
}
Cluster::pointer
Cluster::getById(Wt::Dbo::Session& session, IdType id)
{
+1
View File
@@ -44,6 +44,7 @@ class Cluster : public Wt::Dbo::Dbo<Cluster>
// Find utility
static std::vector<pointer> getAll(Wt::Dbo::Session& session);
static std::vector<pointer> getAllOrphans(Wt::Dbo::Session& session);
static pointer getById(Wt::Dbo::Session& session, IdType id);
// Create utility