From 1cdf2125f5b2dc298dff4cdb67632d9ec8f89f6f Mon Sep 17 00:00:00 2001
From: Daniel <daniel@harvey>
Date: Mon, 27 Apr 2020 13:44:04 +0200
Subject: [PATCH] FIX: more restrictive insertion into isa_cache table

For issue #18
---
 procedures/insertIsaCache.sql | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/procedures/insertIsaCache.sql b/procedures/insertIsaCache.sql
index aacb4cd..a4490bd 100644
--- a/procedures/insertIsaCache.sql
+++ b/procedures/insertIsaCache.sql
@@ -60,7 +60,7 @@ insert_is_a_proc: BEGIN
            p,                            -- New parent (directly)
            concat(p, ">", i.rpath))      -- Else "p>super.rpath"
             AS rpath
-        FROM isa_cache AS i WHERE i.child = p;  -- Select rows with supertype
+        FROM isa_cache AS i WHERE i.child = p AND i.child != i.parent;  -- Select rows with supertype
     
     -- Propagate to descendants:
     -- for each subtype of c: insert each supertype of p
@@ -78,7 +78,7 @@ insert_is_a_proc: BEGIN
             AS rpath
         FROM
             isa_cache as l INNER JOIN isa_cache as r
-            ON (l.parent = c AND c = r.child); -- Left: descendants of c, right: ancestors
+            ON (l.parent = c AND c = r.child AND l.child != l.parent); -- Left: descendants of c, right: ancestors
 	
 END;
 //
-- 
GitLab