Skip to content
Snippets Groups Projects
Commit 2ea500a6 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-fix-merge-key-word' into 'dev'

F fix merge key word

See merge request !70
parents 0f66330a 81a3eeee
No related branches found
No related tags found
2 merge requests!71Release 0.9,!70F fix merge key word
Pipeline #28916 failed
......@@ -338,11 +338,13 @@ def merge_entities(entity_a: Entity, entity_b: Entity):
raise NotImplementedError()
for attribute in ("datatype", "unit", "value"):
if diff_r1["properties"][key][attribute] is None:
setattr(entity_a.get_property(key), attribute,
diff_r2["properties"][key][attribute])
else:
raise RuntimeError("Merge conflict.")
if (attribute in diff_r2["properties"][key] and
diff_r2["properties"][key][attribute] is not None):
if (diff_r1["properties"][key][attribute] is None):
setattr(entity_a.get_property(key), attribute,
diff_r2["properties"][key][attribute])
else:
raise RuntimeError("Merge conflict.")
else:
# TODO: This is a temporary FIX for
# https://gitlab.indiscale.com/caosdb/src/caosdb-pylib/-/issues/105
......
......@@ -296,6 +296,19 @@ def test_merge_entities():
assert r2.get_property("F").value == "text"
def test_merge_bug_conflict():
r = db.Record()
r.add_property(name="C", value=4)
r2 = db.Record()
r2.add_property(name="C", value=4, datatype="TEXT")
merge_entities(r, r2)
r3 = db.Record()
r3.add_property(name="C", value=4, datatype="INTEGER")
with pytest.raises(RuntimeError) as excinfo:
merge_entities(r3, r2)
def test_merge_bug_109():
rt = db.RecordType(name="TestBug")
p = db.Property(name="test_bug_property", datatype=db.LIST(db.INTEGER))
......
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