From 37d28b9e2a1d0b0034c2a69bc14c860871810317 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Fri, 26 May 2023 17:39:11 +0200
Subject: [PATCH] DOC: update CHANGELOG and add source docs

---
 CHANGELOG.md                                                | 2 ++
 src/main/java/org/caosdb/server/database/DatabaseUtils.java | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3c07ca18..4fede81c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed ###
 
+* Unexpected Server Error when inserting an Entity.
+  [#216](https://gitlab.com/caosdb/caosdb-server/-/issues/216)
 * Bad performance due to the execution of unnecessary jobs during retrieval.
   [#189](https://gitlab.com/caosdb/caosdb-server/-/issues/189)
 * Query Language: Parentheses change filter to subproperty filter
diff --git a/src/main/java/org/caosdb/server/database/DatabaseUtils.java b/src/main/java/org/caosdb/server/database/DatabaseUtils.java
index def9b59d..5280de17 100644
--- a/src/main/java/org/caosdb/server/database/DatabaseUtils.java
+++ b/src/main/java/org/caosdb/server/database/DatabaseUtils.java
@@ -96,7 +96,10 @@ 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);
     } else {
       stage1Inserts.add(makeReplacement(p));
-- 
GitLab