Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql	28 Aug 2001 23:51:53 -0000	1.8
+++ openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql	1 Dec 2001 17:55:16 -0000	1.9
@@ -367,19 +367,15 @@
          acs_objects o1, 
          acs_objects o2
     where exists (select 1 
-                    from acs_object_types t
+                    from acs_object_types t, acs_object_types o
                    where t.object_type = o1.object_type
-                     and t.tree_sortkey 
-                         like (select o.tree_sortkey || ''%'' 
-                                 from acs_object_types o
-                                where o.object_type = rt.object_type_one))
+                     and o.object_type = rt.object_type_one
+                     and t.tree_sortkey between o.tree_sortkey and tree_right(o.tree_sortkey))
       and exists (select 1 
-                    from acs_object_types t
+                    from acs_object_types t, acs_object_types o
                    where t.object_type = o2.object_type
-                     and t.tree_sortkey 
-                         like (select o.tree_sortkey || ''%'' 
-                                 from acs_object_types o
-                                where o.object_type = rt.object_type_two))
+                     and o.object_type = rt.object_type_two
+                     and t.tree_sortkey between o.tree_sortkey and tree_right(o.tree_sortkey))
       and rt.rel_type = new.rel_type
       and o1.object_id = new.object_id_one
       and o2.object_id = new.object_id_two;
