go ahead and sort ancestor list by depth so that tree-ification is not strictly required
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 9 Apr 2009 15:46:49 +0000 (15:46 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 9 Apr 2009 15:46:49 +0000 (15:46 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12830 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/020.schema.functions.sql

index d0fc868..2ac4741 100644 (file)
@@ -145,7 +145,8 @@ CREATE OR REPLACE FUNCTION actor.org_unit_ancestors ( INT ) RETURNS SETOF actor.
          FROM  connectby('actor.org_unit'::text,'parent_ou'::text,'id'::text,'name'::text,$1::text,100,'.'::text)
                        AS t(keyid text, parent_keyid text, level int, branch text,pos int)
                JOIN actor.org_unit a ON a.id::text = t.keyid::text
-         ORDER BY  CASE WHEN a.parent_ou IS NULL THEN 0 ELSE 1 END, a.name;
+        JOIN actor.org_unit_type tp ON tp.id = a.ou_type 
+        ORDER BY tp.depth, a.name;
 $$ LANGUAGE SQL STABLE;
 
 CREATE OR REPLACE FUNCTION actor.org_unit_descendants ( INT,INT ) RETURNS SETOF actor.org_unit AS $$