SqliteQueryOption: build(): Handle includeInvisible = true properly

This commit is contained in:
Albert S. 2021-10-12 20:02:03 +02:00
parent 7a2f15cabe
commit c18178a50f
1 changed files with 10 additions and 6 deletions

View File

@ -46,15 +46,18 @@ SqliteQueryOption &SqliteQueryOption::setPrependWhere(bool b)
std::string SqliteQueryOption::build() std::string SqliteQueryOption::build()
{ {
std::string result; std::string result;
if(this->prependWhere)
{
result += "WHERE ";
}
if(!o.includeInvisible && !this->visibleColumnName.empty()) if(!o.includeInvisible && !this->visibleColumnName.empty())
{ {
if(this->prependWhere)
{
result += "WHERE ";
}
result += this->visibleColumnName + " = 1"; result += this->visibleColumnName + " = 1";
} }
else
{
result += " 1 = 1";
}
result += " ORDER BY " + orderByColumnName; result += " ORDER BY " + orderByColumnName;
if(o.order == ASCENDING) if(o.order == ASCENDING)
{ {
@ -66,7 +69,8 @@ std::string SqliteQueryOption::build()
} }
// TODO: limits for offset? // TODO: limits for offset?
if(o.limit > 0) if(o.limit > 0)
{
result += " LIMIT " + std::to_string(o.limit) + " OFFSET " + std::to_string(o.offset); result += " LIMIT " + std::to_string(o.limit) + " OFFSET " + std::to_string(o.offset);
}
return result; return result;
} }