From 7a2f304888c58f61cfd0a918ae9ea573a8d729ba Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Thu, 19 Jun 2025 14:43:01 +0000
Subject: [PATCH] GS-2156
---
lib/db.js | 43 ++++++++++++++++++++++---------------------
1 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/lib/db.js b/lib/db.js
index 0d319c9..d547d86 100644
--- a/lib/db.js
+++ b/lib/db.js
@@ -255,29 +255,30 @@
async function getKursItems2 (ref_id) {
const pool = await poolP
const q = `
- WITH RECURSIVE tree (parent_id, obj_id, ref_id, title, type) AS (SELECT ci.parent_id,
- or2.obj_id,
- ci.obj_id as ref_id,
- od.title,
- od.type
- FROM ${database}.crs_items ci
- INNER JOIN ${database}.object_reference or2 ON or2.ref_id = ci.obj_id
- INNER JOIN ${database}.object_data od ON od.obj_id = or2.obj_id
- WHERE ci.obj_id = ${ref_id} -- Kurs ref_id
- AND or2.deleted is NULL
+ WITH RECURSIVE tree (parent_id, obj_id, ref_id, title, type) AS
+ (SELECT ci.parent_id,
+ or2.obj_id,
+ ci.obj_id as ref_id,
+ od.title,
+ od.type
+ FROM ${database}.crs_items ci
+ INNER JOIN ${database}.object_reference or2 ON or2.ref_id = ci.obj_id
+ INNER JOIN ${database}.object_data od ON od.obj_id = or2.obj_id
+ WHERE ci.obj_id = ${ref_id} -- Kurs ref_id
+ AND or2.deleted is NULL
- UNION ALL
+ UNION ALL
- SELECT child.parent_id,
- or2.obj_id,
- child.obj_id as ref_id,
- od.title,
- od.type
- FROM ${database}.crs_items child
- INNER JOIN ${database}.object_reference or2 ON or2.ref_id = child.obj_id
- INNER JOIN ${database}.object_data od ON od.obj_id = or2.obj_id
- JOIN tree ON child.parent_id = tree.ref_id
- WHERE or2.deleted is NULL)
+ SELECT child.parent_id,
+ or2.obj_id,
+ child.obj_id as ref_id,
+ od.title,
+ od.type
+ FROM ${database}.crs_items child
+ INNER JOIN ${database}.object_reference or2 ON or2.ref_id = child.obj_id
+ INNER JOIN ${database}.object_data od ON od.obj_id = or2.obj_id
+ JOIN tree ON child.parent_id = tree.ref_id
+ WHERE or2.deleted is NULL)
SELECT *
FROM tree
ORDER BY tree.ref_id
--
Gitblit v1.8.0