From 5e2f03b94e5043c0898f2b3b937f296d88d8259e Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Tue, 26 May 2020 15:48:08 +0200
Subject: [PATCH] Some code comments

---
 CHANGELOG.md                    | 1 -
 procedures/entityVersioning.sql | 9 +++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 44bcea8..e1b9e5a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,4 +19,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### Fixed ###
 
 - Fixed several bugs when an Entity inherits from itself (#18, caosdb-server #85).
->>>>>>> dev
diff --git a/procedures/entityVersioning.sql b/procedures/entityVersioning.sql
index f6d4665..298fefa 100644
--- a/procedures/entityVersioning.sql
+++ b/procedures/entityVersioning.sql
@@ -125,6 +125,11 @@ BEGIN
 END;
 //
 
+
+-- This implementation assumes that the distance from the head equals the
+-- difference between the _iversion numbers. This will not be correct anymore,
+-- as soon as branches may split and merge. Then, an tree-walk will be
+-- necessary, traversing the primary parents (_pparent), will be necessary.
 DROP FUNCTION IF EXISTS db_2_0.get_head_relative //
 CREATE FUNCTION db_2_0.get_head_relative(
     EntityID INT UNSIGNED,
@@ -157,6 +162,10 @@ BEGIN
         WHERE c.entity_id = EntityID
         AND c._ipparent is Null
 
+    -- TODO This first SELECT statement is necessary because the second one
+    -- does not return the root. However, this should be doable in one go with
+    -- a left join.
+
     -- retrieve branches
     UNION SELECT c.version AS child,
             p.version AS parent,
-- 
GitLab