Fix #7164. Property facets with a restriction in the baseName would incorrectly test null values.

Our tests missed this detail. The previous test also did
should_purge=True by default which doesn't property test for nullness.
This commit is contained in:
Dion Moult
2025-09-30 00:07:14 +10:00
parent 6da51c2a6e
commit 2027c71d99
2 changed files with 7 additions and 2 deletions
+3 -1
View File
@@ -688,7 +688,9 @@ class Property(Facet):
elif prop is not None and prop != "":
props[pset_name][self.baseName] = prop
else:
props[pset_name] = {k: v for k, v in pset_props.items() if k == self.baseName}
props[pset_name] = {
k: v for k, v in pset_props.items() if k == self.baseName and v is not None and v != ""
}
if not bool(props[pset_name]):
if self.cardinality == "optional":
+4 -1
View File
@@ -921,8 +921,11 @@ class TestProperty:
pset = ifcopenshell.api.pset.add_pset(ifc, product=element, name="Foo_Bar")
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"AnotherProperty": "AnotherValue"})
run("Elements with a matching pset but no property also fail", facet=facet, inst=element, expected=False)
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"AnotherProperty": None})
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"Foo": None}, should_purge=False)
run("Properties with a null value fail", facet=facet, inst=element, expected=False)
restriction = Restriction(options={"pattern": "Fo.*"})
facet = Property(propertySet="Foo_Bar", baseName=restriction, dataType="IFCLABEL")
run("Pattern matched properties with a null value fail", facet=facet, inst=element, expected=False)
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"Foo": "Bar"})
run("A name check will match any property with any string value", facet=facet, inst=element, expected=True)