From e863b5261b7eb04599a4ee00118c3ffd165ecd90 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 4 Nov 2018 20:08:39 +0100 Subject: [PATCH] revisiondaosqlite: Don't ignore page visibility setting --- database/revisiondaosqlite.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/database/revisiondaosqlite.cpp b/database/revisiondaosqlite.cpp index d735e76..909a029 100644 --- a/database/revisiondaosqlite.cpp +++ b/database/revisiondaosqlite.cpp @@ -51,11 +51,15 @@ std::vector RevisionDaoSqlite::getAllRevisions(QueryOption &options) try { SqliteQueryOption queryOption{options}; - std::string queryOptionSql = queryOption.setPrependWhere(true).setOrderByColumn("id").build(); - - auto query = *db << "SELECT author, comment, content, strftime('%s',creationtime), (SELECT name FROM page " - "WHERE page.id = page ), revisionid FROM revision " + - queryOptionSql; + std::string queryOptionSql = queryOption.setPrependWhere(true) + .setVisibleColumnName("page.visible") + .setOrderByColumn("revisionid") + .build(); + auto query = + *db + << "SELECT (SELECT username FROM user WHERE id = author), comment, content, strftime('%s',creationtime), " + "page.name, revisionid FROM revision INNER JOIN page ON revision.page = page.id " + + queryOptionSql; query >> [&](std::string author, std::string comment, std::string content, time_t creationtime, std::string page, unsigned int revisionid) { Revision r; @@ -86,11 +90,13 @@ std::vector RevisionDaoSqlite::getAllRevisionsForPage(std::string page try { SqliteQueryOption queryOption{option}; - std::string queryOptionSql = queryOption.setPrependWhere(false).setOrderByColumn("id").build(); - + std::string queryOptionSql = queryOption.setPrependWhere(false) + .setVisibleColumnName("page.visible") + .setOrderByColumn("revisionid") + .build(); auto query = *db << "SELECT (SELECT username FROM user WHERE id = author), comment, content, " - "strftime('%s',creationtime), (SELECT name FROM page WHERE page.id = page ), revisionid " - "FROM revision WHERE page = (SELECT id FROM page WHERE name = ?) " + + "strftime('%s',creationtime), page.name, revisionid FROM revision INNER JOIN page ON " + "revision.page = page.id WHERE page.name = ? AND " + queryOptionSql << pagename;