From c18178a50f7648d04dff10fddb055815ad486bec Mon Sep 17 00:00:00 2001 From: Albert S Date: Tue, 12 Oct 2021 20:02:03 +0200 Subject: [PATCH] SqliteQueryOption: build(): Handle includeInvisible = true properly --- database/sqlitequeryoption.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/database/sqlitequeryoption.cpp b/database/sqlitequeryoption.cpp index 2adbd30..ea9742c 100644 --- a/database/sqlitequeryoption.cpp +++ b/database/sqlitequeryoption.cpp @@ -46,15 +46,18 @@ SqliteQueryOption &SqliteQueryOption::setPrependWhere(bool b) std::string SqliteQueryOption::build() { std::string result; + if(this->prependWhere) + { + result += "WHERE "; + } if(!o.includeInvisible && !this->visibleColumnName.empty()) { - if(this->prependWhere) - { - result += "WHERE "; - } result += this->visibleColumnName + " = 1"; } - + else + { + result += " 1 = 1"; + } result += " ORDER BY " + orderByColumnName; if(o.order == ASCENDING) { @@ -66,7 +69,8 @@ std::string SqliteQueryOption::build() } // TODO: limits for offset? if(o.limit > 0) + { result += " LIMIT " + std::to_string(o.limit) + " OFFSET " + std::to_string(o.offset); - + } return result; }