From 233c30b66ba2b1b134a70fbc127f915c1126c420 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sat, 27 Apr 2019 21:23:06 +0200 Subject: [PATCH] search: fixed: order by after group by in content search --- shared/sqlitesearch.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/sqlitesearch.cpp b/shared/sqlitesearch.cpp index 71e4a99..b2f5838 100644 --- a/shared/sqlitesearch.cpp +++ b/shared/sqlitesearch.cpp @@ -107,7 +107,7 @@ QString SqliteSearch::createSortSql(const SqliteSearch::Token &token) //sort:(mtime desc, page asc) if(token.key == "sort") { - QString sortsql = " ORDER BY "; + QString sortsql; QStringList splitted_inner = token.value.split(","); for(int i = 0; i < splitted_inner.length(); i++) { @@ -231,7 +231,7 @@ QSqlQuery SqliteSearch::makeSqlQuery(const QVector &tokens) { sortSql = "ORDER BY file.mtime DESC, content.page ASC"; } - prepSql = "SELECT file.path AS path, group_concat(content.page) AS pages, file.mtime AS mtime, file.size AS size, file.filetype AS filetype FROM file INNER JOIN content ON file.id = content.fileid WHERE 1=1 AND " + whereSql + " " + sortSql + " GROUP BY file.path"; + prepSql = "SELECT file.path AS path, group_concat(content.page) AS pages, file.mtime AS mtime, file.size AS size, file.filetype AS filetype FROM file INNER JOIN content ON file.id = content.fileid WHERE 1=1 AND " + whereSql + " GROUP BY file.path " + sortSql; } else { @@ -266,6 +266,7 @@ QVector SqliteSearch::search(const QString &query) { qDebug() << dbQuery.lastError(); + qDebug() << dbQuery.executedQuery(); throw QSSGeneralException("SQL Error: " + dbQuery.lastError().text()); }