This commit is contained in:
2020-03-18 18:07:16 +00:00
parent 6936186806
commit ea235a9a0c

View File

@@ -196,47 +196,51 @@ namespace AyaNova.PickList
sb.Append(pickList.SQLFrom); sb.Append(pickList.SQLFrom);
//WHERE //WHERE
sb.Append(" where "); //there is a condition where there is no where (inactive=true and no query of any kind)
if (lWhere.Count > 0 || HasTagSpecificQuery || IncludeInactive)
if (HasTagSpecificQuery)
{ {
sb.Append(TagSpecificWhereFragment); sb.Append(" where ");
sb.Append(" and ");
}
if (!IncludeInactive) if (HasTagSpecificQuery)
{
sb.Append(ActiveWhereFragment);
sb.Append(" and ");
}
if (lWhere.Count > 0)
{
//Put all the regular query terms in parenthesis to ensure it's all treated as one criteria
sb.Append("(");
foreach (string s in lWhere)
{ {
sb.Append(s); sb.Append(TagSpecificWhereFragment);
sb.Append(" or "); sb.Append(" and ");
} }
//clear trailing or
sb.Length -= 4; if (!IncludeInactive)
//enclosing parenthesis
sb.Append(")");
}
else
{
//we might have a trailing and to remove
//jesus this stuff sucks, there must be a better way, it seems so fragile
if (!IncludeInactive || HasTagSpecificQuery)
{ {
//trailing " and " to remove sb.Append(ActiveWhereFragment);
sb.Length -= 5; sb.Append(" and ");
}
if (lWhere.Count > 0)
{
//Put all the regular query terms in parenthesis to ensure it's all treated as one criteria
sb.Append("(");
foreach (string s in lWhere)
{
sb.Append(s);
sb.Append(" or ");
}
//clear trailing or
sb.Length -= 4;
//enclosing parenthesis
sb.Append(")");
}
else
{
//we might have a trailing and to remove
//jesus this stuff sucks, there must be a better way, it seems so fragile
if (!IncludeInactive || HasTagSpecificQuery)
{
//trailing " and " to remove
sb.Length -= 5;
}
} }
} }