_and and _or don't process List parameters correctly
Summary: If you pass Lists as parameters to _and
or _or
, only the first element of each List is used, not the entire thing. This is as-documented, but bad for some use cases, so it should be fixed.
Original title: Applying _and to a List of TrueFalse values sometimes returns the value of the first item rather than and-ing (possibly a problem with _or as well?)
Original Details:
(The specific case below is no longer relevant to me because _contains / _isContainedIn have been implemented, but it's a useful illustration of the bug.)
I defined a "Has Subset" function:
+$items
_and(
$_1 -> _foreach(
_isContainedIn($items)
)
)
Case 1: <1, 2, 3, 4, 5> -> Has Subset(<1, 6, 3, 7>)
yields true
Case 2: <1, 2, 3, 4, 5> -> Has Subset(<6, 1, 3, 7>)
yields false
If I remove the _and
from the function, it's building up a list of boolean values just fine:
+$items
$_1 -> _foreach(
_isContainedIn($items)
)
Case 3: <1, 2, 3, 4, 5> -> Has Subset(<1, 6, 3, 7>)
yields true false true false
Case 4: <1, 2, 3, 4, 5> -> _and(Has Subset(<1, 6, 3, 7>))
yields false
The fact that Case 1 and Case 4 differ is pretty clearly wrong.
EDIT: This may be a problem with _or
as well - in another space, I logged:
On the PnP Updates page:
_instances -> _groupBy(Update Status) -> _sort(_groupKey -> Sort Order) ->
_if(
_or(
_greaterThan(_groupKey -> Sort Order, 1),
Testing Requests -> _hasPermission(Who Can Create._self)
),
""### [[_groupKey -> Name]]
[[_greaterThan(_groupKey -> Sort Order, 1)]]
"")
The QL phrase _greaterThan(_groupKey -> Sort Order, 1),
displays just what you'd expect - false
for the first Update Status, true
for the later ones - but it is seemingly ignored in the _or
; if you don't have the permission specified in the 2nd half of the _or
clause, the QL above shows nothing at all despite there being a number of items with an Update Status -> Sort Order
greater than 1.