This commit is contained in:
@@ -196,47 +196,51 @@ namespace AyaNova.PickList
|
||||
sb.Append(pickList.SQLFrom);
|
||||
|
||||
|
||||
//WHERE
|
||||
sb.Append(" where ");
|
||||
|
||||
if (HasTagSpecificQuery)
|
||||
//WHERE
|
||||
//there is a condition where there is no where (inactive=true and no query of any kind)
|
||||
if (lWhere.Count > 0 || HasTagSpecificQuery || IncludeInactive)
|
||||
{
|
||||
sb.Append(TagSpecificWhereFragment);
|
||||
sb.Append(" and ");
|
||||
}
|
||||
sb.Append(" where ");
|
||||
|
||||
if (!IncludeInactive)
|
||||
{
|
||||
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)
|
||||
if (HasTagSpecificQuery)
|
||||
{
|
||||
sb.Append(s);
|
||||
sb.Append(" or ");
|
||||
sb.Append(TagSpecificWhereFragment);
|
||||
sb.Append(" and ");
|
||||
}
|
||||
//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)
|
||||
if (!IncludeInactive)
|
||||
{
|
||||
//trailing " and " to remove
|
||||
sb.Length -= 5;
|
||||
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(" 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user