Skip to content
Snippets Groups Projects
Commit 544bc63a authored by florian's avatar florian
Browse files

FIX: Raise correct error, but don't infer list datatypes

parent bf6ca5e0
No related branches found
No related tags found
2 merge requests!93Release 0.11.0,!92F merge missing list datatype
Pipeline #32563 passed
......@@ -25,8 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ###
* [#82](https://gitlab.com/caosdb/caosdb-pylib/-/issues/82) Merging an entity
with properties with missing datatype leads to Exception - list datatypes are
now inferred from scalar datatype in force merges.
with properties with missing datatype leads to Exception - The correct
exception is raised in case of a missing LIST datatype.
### Security ###
......
......@@ -442,16 +442,6 @@ def merge_entities(entity_a: Entity, entity_b: Entity, merge_references_with_emp
setattr(entity_a.get_property(key), attribute,
diff_r2["properties"][key][attribute])
elif force:
if attribute == "value":
# Very special case of a property that has a scalar
# datatype being fored to a list value without
# having been assigned the correct datatype before.
if isinstance(diff_r2["properties"][key][attribute], list):
if ((entity_a.get_property(key).datatype is not None) and
(not entity_a.get_property(key).datatype.startswith("LIST<"))):
entity_a.get_property(key).datatype = LIST(
entity_a.get_property(key).datatype)
setattr(entity_a.get_property(key), attribute,
diff_r2["properties"][key][attribute])
else:
......
......@@ -571,5 +571,6 @@ def test_merge_missing_list_datatype_82():
recA = db.Record().add_property("a", 5, datatype="B")
recB_without_DT = db.Record().add_property("a", [1, 2])
with pytest.raises(TypeError) as te:
merge_entities(recA, recB_without_DT, force=True)
assert recA.get_property("a").datatype == "LIST<B>"
assert "Invalid datatype: List valued properties" in str(te.value)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment