X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/ac35af3aef24ba0b644f85b0fe98492e9065af1d..5ba01432d80e839e2c6240717225017635cba28f:/tools/word.pg.sql

diff --git a/tools/word.pg.sql b/tools/word.pg.sql
index 6647370..9f6bd41 100644
--- a/tools/word.pg.sql
+++ b/tools/word.pg.sql
@@ -81,18 +81,19 @@ CREATE OR REPLACE VIEW _word_ref AS
 
 CREATE OR REPLACE VIEW _word_tree AS
 	WITH RECURSIVE r AS (
-		SELECT w.ref, w.lang, w.cat, w.grade, NULL::int trans
+		SELECT w.ref, w.lang, w.cat, w.grade, w.form, NULL::int trans
 		FROM _word_ref w
 	UNION ALL
 		SELECT r.ref, r.lang, w.cat,
 			CASE WHEN w.lang=r.lang OR t.lang=r.lang THEN r.grade ELSE w.grade END,
+			CASE WHEN w.lang=r.lang OR t.lang=r.lang THEN r.form ELSE w.form END,
 			CASE WHEN w.lang=r.lang OR t.lang=r.lang THEN w.id END
 		FROM r JOIN word w ON w.id = r.cat
 		  LEFT JOIN word t ON w.id = t.ref AND t.lang = r.lang
 		WHERE r.trans IS NULL
 	)
-	SELECT ref, lang, trans cat, grade FROM r WHERE trans IS NOT NULL
-		ORDER BY cat, grade, ref;
+	SELECT ref, lang, trans cat, grade, form FROM r WHERE trans IS NOT NULL
+		ORDER BY cat, grade, form, ref;
 
 CREATE OR REPLACE VIEW _word AS
 	SELECT
