mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
Selector: negate list comparisons as an aggregate #8129
compare() recursed into list values passing the negated comparison through,
so != meant "at least one item differs" and both = and != matched the same
elements on any multi-valued property (e.g. an enumerated property with two
values selected). Strip the negation for the per-item comparison and negate
the aggregate instead, so != means "no item equals" and stays the complement
of =. The same applies to !*=.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit 209c44db83)
This commit is contained in:
committed by
Dion Moult
parent
ad6f9bbbf6
commit
f761156dea
@@ -1246,7 +1246,13 @@ class FacetTransformer(lark.Transformer):
|
||||
|
||||
def compare(self, element_value, comparison, value) -> bool:
|
||||
if isinstance(element_value, (list, tuple)):
|
||||
return any(self.compare(ev, comparison, value) for ev in element_value)
|
||||
# Match if any item does, negating the aggregate rather than each
|
||||
# item, so that e.g. != means "no item equals" and stays the
|
||||
# complement of = (#8129).
|
||||
result = any(self.compare(ev, comparison.lstrip("!"), value) for ev in element_value)
|
||||
if comparison.startswith("!"):
|
||||
return not result
|
||||
return result
|
||||
elif isinstance(value, str):
|
||||
try:
|
||||
if isinstance(element_value, int):
|
||||
|
||||
Reference in New Issue
Block a user