From 07c540b1e1c01dcf7fd3ee22b2fb8ce78d0ba19d Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Thu, 12 Oct 2023 15:13:30 +0200
Subject: [PATCH] STY: Mainly styling and typos.

---
 CHANGELOG.md                                |  2 +-
 patches/patch20221122-6.0-SNAPSHOT/patch.sh |  4 +-
 procedures/getDependentEntities.sql         | 54 ++++++++++-----------
 procedures/insertEntity.sql                 |  2 +-
 procedures/overrideName.sql                 |  2 +-
 procedures/query/initBackReference.sql      |  4 +-
 procedures/query/initPOV.sql                |  8 +--
 procedures/query/initSubEntity.sql          |  4 +-
 procedures/retrieveEntityOverrides.sql      |  8 +--
 procedures/retrieveEntityProperties.sql     |  2 +-
 10 files changed, 47 insertions(+), 43 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5bc1533..d674221 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -51,7 +51,7 @@ This is a major update. Switching from integer ids for internal and external use
 ### Removed ###
 
 * Deactivate procedure `delete_all_entity_versions`. This might be used in the
-  future, that why we keep the code in a comment.
+  future, that is why we keep the code in a comment.
 * Drop procedure `retrieveSubEntity`
 * Drop procedure `retrieveDatatype`
 * Drop procedure `retrieveGroup`
diff --git a/patches/patch20221122-6.0-SNAPSHOT/patch.sh b/patches/patch20221122-6.0-SNAPSHOT/patch.sh
index 7348ac0..54208ab 100755
--- a/patches/patch20221122-6.0-SNAPSHOT/patch.sh
+++ b/patches/patch20221122-6.0-SNAPSHOT/patch.sh
@@ -2,8 +2,8 @@
 #
 # This file is a part of the CaosDB Project.
 #
-# Copyright (C) 2022 IndiScale GmbH <info@indiscale.com>
-# Copyright (C) 2022 Timm Fitschen <t.fitschen@indiscale.com>
+# Copyright (C) 2023 IndiScale GmbH <info@indiscale.com>
+# Copyright (C) 2023 Timm Fitschen <t.fitschen@indiscale.com>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as
diff --git a/procedures/getDependentEntities.sql b/procedures/getDependentEntities.sql
index 6272fd0..0940e44 100644
--- a/procedures/getDependentEntities.sql
+++ b/procedures/getDependentEntities.sql
@@ -26,10 +26,10 @@ DROP PROCEDURE IF EXISTS db_5_0.getDependentEntities;
 delimiter //
 
 /*
- * Return all entities which either reference the given entity, use the given *
+ * Return all entities which either reference the given entity, use the given
  * reference as data type, or are direct children of the given entity.
  *
- * This function is being used to make sure that no entity can be deleted which
+ * This function used to make sure that no entity can be deleted which
  * is still needed by others.
  *
  * Parameters
@@ -47,48 +47,48 @@ BEGIN
 
     DECLARE InternalEntityID INT UNSIGNED DEFAULT NULL;
 
-    DROP TEMPORARY TABLE IF EXISTS refering;
-    CREATE TEMPORARY TABLE refering (
+    DROP TEMPORARY TABLE IF EXISTS referring;
+    CREATE TEMPORARY TABLE referring (
         id INT UNSIGNED UNIQUE
     );
 
     SELECT internal_id INTO InternalEntityID from entity_ids WHERE id = EntityID;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id FROM reference_data WHERE (value=InternalEntityID OR property_id=InternalEntityID) AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id FROM reference_data WHERE (value=InternalEntityID OR property_id=InternalEntityID) AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
+    INSERT IGNORE INTO referring (id) SELECT entity_id FROM reference_data WHERE (value=InternalEntityID OR property_id=InternalEntityID) AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id FROM reference_data WHERE (value=InternalEntityID OR property_id=InternalEntityID) AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id FROM text_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id FROM text_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
+    INSERT IGNORE INTO referring (id) SELECT entity_id FROM text_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id FROM text_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id FROM enum_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id FROM enum_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
+    INSERT IGNORE INTO referring (id) SELECT entity_id FROM enum_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id FROM enum_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id FROM name_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id FROM name_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
+    INSERT IGNORE INTO referring (id) SELECT entity_id FROM name_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id FROM name_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id FROM integer_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id FROM integer_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
+    INSERT IGNORE INTO referring (id) SELECT entity_id FROM integer_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id FROM integer_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id FROM double_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id FROM double_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
+    INSERT IGNORE INTO referring (id) SELECT entity_id FROM double_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id FROM double_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id FROM datetime_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id FROM datetime_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
+    INSERT IGNORE INTO referring (id) SELECT entity_id FROM datetime_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id FROM datetime_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id FROM date_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id FROM date_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
+    INSERT IGNORE INTO referring (id) SELECT entity_id FROM date_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id FROM date_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id FROM null_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id FROM null_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
+    INSERT IGNORE INTO referring (id) SELECT entity_id FROM null_data WHERE property_id=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id FROM null_data WHERE property_id=InternalEntityID AND domain_id!=InternalEntityID AND entity_id!=InternalEntityID AND domain_id!=0;
 
-    INSERT IGNORE INTO refering (id) SELECT entity_id from data_type WHERE datatype=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
-    INSERT IGNORE INTO refering (id) SELECT domain_id from data_type WHERE datatype=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT entity_id from data_type WHERE datatype=InternalEntityID AND domain_id=0 AND entity_id!=InternalEntityID;
+    INSERT IGNORE INTO referring (id) SELECT domain_id from data_type WHERE datatype=InternalEntityID;
 
-    INSERT IGNORE INTO refering (id) SELECT child FROM isa_cache WHERE parent = InternalEntityID AND rpath=child;
+    INSERT IGNORE INTO referring (id) SELECT child FROM isa_cache WHERE parent = InternalEntityID AND rpath = child;
 
-    SELECT e.id FROM refering AS r LEFT JOIN entity_ids AS e ON r.id = e.internal_id WHERE r.id!=0 AND e.internal_id!=InternalEntityID;
+    SELECT e.id FROM referring AS r LEFT JOIN entity_ids AS e ON r.id = e.internal_id WHERE r.id!=0 AND e.internal_id!=InternalEntityID;
 
-    DROP TEMPORARY TABLE refering;
+    DROP TEMPORARY TABLE referring;
 
 END;
 //
diff --git a/procedures/insertEntity.sql b/procedures/insertEntity.sql
index 4b385f2..816fe8b 100644
--- a/procedures/insertEntity.sql
+++ b/procedures/insertEntity.sql
@@ -53,7 +53,7 @@ BEGIN
     DECLARE Transaction VARBINARY(255) DEFAULT NULL;
     DECLARE InternalEntityID INT UNSIGNED DEFAULT NULL;
 
-    -- insert the acl. the new acl id is being written (c-style) into the
+    -- insert the acl. The new acl id is written (c-style) into the
     -- variable NewACLID.
     call entityACL(NewACLID, ACL);
 
diff --git a/procedures/overrideName.sql b/procedures/overrideName.sql
index b651c49..cbd74fd 100644
--- a/procedures/overrideName.sql
+++ b/procedures/overrideName.sql
@@ -26,7 +26,7 @@ DROP PROCEDURE IF EXISTS db_5_0.overrideType;
 
 DELIMITER //
 /*
- *Insert a name override.
+ * Insert a name override.
  *
  * Parameters
  * ----------
diff --git a/procedures/query/initBackReference.sql b/procedures/query/initBackReference.sql
index 0a5be1b..2999fb9 100644
--- a/procedures/query/initBackReference.sql
+++ b/procedures/query/initBackReference.sql
@@ -26,12 +26,12 @@ DELIMITER //
 /*
  * Create and initialize two new temporary tables.
  *
- * This is being used to initialize the filterin for backreferences to a
+ * This is used to initialize the filterin for backreferences to a
  * particular entity (specified by EntityID or EntityName) or using a
  * particular property (specified by PropertyID or PropertyName).
  *
  * The propertiesTable contains all properties matching the PropertyID or
- * PropertyName. The entitiesTable container all entities matching EntityID or
+ * PropertyName. The entitiesTable contains all entities matching EntityID or
  * EntityName.
 
  * Parameters
diff --git a/procedures/query/initPOV.sql b/procedures/query/initPOV.sql
index 6971329..31347ba 100644
--- a/procedures/query/initPOV.sql
+++ b/procedures/query/initPOV.sql
@@ -27,8 +27,8 @@ DROP PROCEDURE IF EXISTS db_5_0.initPOVPropertiesTable//
 /*
  * Create and initialize a new temporary table.
  *
- * This is being used to initialize the POV filtering. The resulting table
- * container all properties machting the Property component of the POV filter.
+ * This is used to initialize the POV filtering. The resulting table
+ * contains all properties matching the Property component of the POV filter.
  *
  * Parameters
  * ----------
@@ -112,8 +112,8 @@ DROP PROCEDURE IF EXISTS db_5_0.initPOVRefidsTable //
 /*
  * Create and initialize a new temporary table.
  *
- * This is being used to initialize the POV filtering. The resulting table
- * container all entities machting the Value component of the POV filter (i.e.
+ * This used to initialize the POV filtering. The resulting table
+ * contains all entities matching the Value component of the POV filter (i.e.
  * the referenced entities).
  *
  * Parameters
diff --git a/procedures/query/initSubEntity.sql b/procedures/query/initSubEntity.sql
index 6bddd13..c60ddb6 100644
--- a/procedures/query/initSubEntity.sql
+++ b/procedures/query/initSubEntity.sql
@@ -3,6 +3,8 @@
  *
  * Copyright (C) 2018 Research Group Biomedical Physics,
  * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
+ * Copyright (C) 2023 IndiScale GmbH <info@indiscale.com>
+ * Copyright (C) 2023 Timm Fitschen <t.fitschen@indiscale.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -24,7 +26,7 @@ DROP PROCEDURE IF EXISTS db_5_0.initSubEntity;
 DELIMITER //
 
 /*
- * Initialize a new temporary by loading an entity and all of it's children
+ * Initialize a new temporary table by loading an entity and all of its children
  * into the table (i.e. their internal ids).
  *
  * This is used by initPOVRefidsTable and initBackReference for sub-property filtering.
diff --git a/procedures/retrieveEntityOverrides.sql b/procedures/retrieveEntityOverrides.sql
index 61a28a0..f552a2c 100644
--- a/procedures/retrieveEntityOverrides.sql
+++ b/procedures/retrieveEntityOverrides.sql
@@ -24,7 +24,7 @@ DROP PROCEDURE IF EXISTS db_5_0.retrieveOverrides;
 delimiter //
 
 /*
- * Retrieve the overriden (overwriting the Abstract Property's) name, description, and datatype.
+ * Retrieve the overridden (overriding the Abstract Property's) name, description, and datatype.
  *
  * Parameters
  * ----------
@@ -44,7 +44,7 @@ delimiter //
  * type_override,       # the datatype, e.g. DOUBLE
  * entity_id,           # same as input EntityID
  * InternalPropertyID,  # internal property id, to be used when property_id
- *                      # is NULL because a replacement is being using.
+ *                      # is NULL because a replacement is used.
  * property_id,         # the property id
  */
 CREATE PROCEDURE db_5_0.retrieveOverrides(
@@ -62,7 +62,9 @@ retrieveOverridesBody: BEGIN
     -- which are internal ids by definition (and do not have external
     -- equivalents). That's why we do the UNION here, falling back to the
     -- EntityID.
-    SELECT temp.internal_id INTO InternalEntityID FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = EntityID UNION SELECT EntityID AS internal_id) AS temp LIMIT 1;
+    SELECT temp.internal_id INTO InternalEntityID
+       FROM (SELECT internal_id AS internal_id FROM
+             entity_ids WHERE id = EntityID UNION SELECT EntityID AS internal_id) AS temp LIMIT 1;
     -- DomainID != 0 are always normal (i.e. external) Entity ids.
     SELECT internal_id INTO InternalDomainID from entity_ids WHERE id = DomainID;
 
diff --git a/procedures/retrieveEntityProperties.sql b/procedures/retrieveEntityProperties.sql
index a7026d9..024f3b0 100644
--- a/procedures/retrieveEntityProperties.sql
+++ b/procedures/retrieveEntityProperties.sql
@@ -42,7 +42,7 @@ drop procedure if exists db_5_0.retrieveEntityProperties //
  * ---------
  * InternalPropertyID
  *     Internal property id, to be used when PropertyID
- *     is NULL because a replacement is being using.
+ *     is NULL because a replacement is used.
  * PropertyID
  *     The property id
  * PropertyValue
-- 
GitLab