Skip to content
Snippets Groups Projects
Commit 642802e1 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

fix filtered Attributes - load nothing if empty array or only invalid ids

parent 8b3368a0
No related branches found
No related tags found
No related merge requests found
......@@ -72,18 +72,25 @@ else if (showEmpty || objectRowId)
attributeSql.andIfSet("AB_ATTRIBUTE.AB_ATTRIBUTEID", possibleAttributes, SqlBuilder.IN());
}
if (vars.exists("$param.FilteredAttributeIds_param") && vars.getString("$param.FilteredAttributeIds_param"))
if (vars.get("$param.FilteredAttributeIds_param"))
{
let filteredIds = JSON.parse(vars.getString("$param.FilteredAttributeIds_param"));
let filteredIdChildren = AttributeUtil.getAllChildren(filteredIds);
let filteredCondition = newWhereIfSet("AB_ATTRIBUTE.AB_ATTRIBUTEID", filteredIdChildren, SqlBuilder.IN())
.and("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE, "# != ?");
let filteredCondition = newWhere();
if (filteredIdChildren.length > 0)
{
filteredCondition.and("AB_ATTRIBUTE.AB_ATTRIBUTEID", filteredIdChildren, SqlBuilder.IN())
.and("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE, "# != ?");
}
// return nothing if filteredAttributeIds is an empty array. (--> and 1=2)
if (filteredIds && filteredIds.length > 0)
if (filteredCondition.hasCondition())
attributeSql.and(filteredCondition);
else
attributeSql.and("1=2");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment