Skip to content
Snippets Groups Projects
Merged Timm Fitschen requested to merge f-server-216 into dev
2 unresolved threads
Files
2
@@ -96,7 +96,11 @@ public class DatabaseUtils {
&& !p.isDatatypeOverride()
&& (!p.hasProperties() || hasUniquePropertyId(p, e))
&& !(p.getDatatype() instanceof AbstractCollectionDatatype)) {
// if p has no sub-properties, just add it
// this property can be represented without any replacement. We explicitly
// setReplacement(null) because there is a corner case (related to the inheritance of
// properties) where there is a replacement present which belongs to the parent entity, see
// https://gitlab.com/caosdb/caosdb-server/-/issues/216.
p.setReplacement(null);
    • Author Owner

      The problem results from a non-null replacement in a property which should not have a replacement. The non-null replacement is a residual from a previous run of this method's else clause (below) on the property of the parent entity (in the same transaction).

      A bit of context: Both the child's and the parent's properties are wrapping the same object under the hood. This wrapping is caused by the inheritance job. However, since the replacement is just a implementation detail and only needed for the correct storage of properties in the backend, we can simple remove it here, because the parent entity has already been written to backend.

      For completeness, there is another possibility for a fix: We could, at some earlier point, disentangle the parent's and the child's property by cloning the underlying object. However, this seems to be much more hassle, because the nice thing about them sharing the same property object under the hood is that we don't need to update them both when id's are being resolved, the description, the datatype or other additional information is added (during inserts) and so on... And this convenience was just the reason why they share the same object in the first place.

      Edited by Timm Fitschen
Please register or sign in to reply
} else {
stage1Inserts.add(makeReplacement(p));
    • Author Owner

      NOTE: Previously, the bug occurred when this line (i.e. the else clause) is executed on the parent but not on the child, because this line sets a replacement.

Please register or sign in to reply
}
Loading