You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT d.conceptidfrom, d.conceptidto, c2.value, c2.valueid as valueid, c.value as valueto, c.valueid as valueidto, c.valuetype as vtype, 1 AS depth, array[d.conceptidto] AS conceptpath, array[c.valueid] AS idpath ---|NonRecursive Part
1183
-
FROM relations d
1184
-
JOIN values c ON(c.conceptid = d.conceptidto)
1185
-
JOIN values c2 ON(c2.conceptid = d.conceptidfrom)
1186
-
WHERE d.conceptidfrom = '{0}'
1187
-
and c2.valuetype = 'prefLabel'
1188
-
and c.valuetype in ('prefLabel', 'sortorder', 'collector')
1189
-
and (d.relationtype = 'member' or d.relationtype = 'hasTopConcept')
1190
-
UNION
1191
-
SELECT d.conceptidfrom, d.conceptidto, v2.value, v2.valueid as valueid, v.value as valueto, v.valueid as valueidto, v.valuetype as vtype, depth+1, (conceptpath || d.conceptidto), (idpath || v.valueid) ---|RecursivePart
1192
-
FROM relations d
1193
-
JOIN children b ON(b.conceptidto = d.conceptidfrom)
1194
-
JOIN values v ON(v.conceptid = d.conceptidto)
1195
-
JOIN values v2 ON(v2.conceptid = d.conceptidfrom)
1196
-
WHERE v2.valuetype = 'prefLabel'
1197
-
and v.valuetype in ('prefLabel','sortorder', 'collector')
1198
-
and (d.relationtype = 'member' or d.relationtype = 'hasTopConcept')
1199
-
) SELECT conceptidfrom::text, conceptidto::text, value, valueid::text, valueto, valueidto::text, depth, idpath::text, conceptpath::text, vtype FROM children ORDER BY depth, conceptpath;
1200
-
""".format(
1201
-
conceptid
1189
+
cursor.execute(
1190
+
"""
1191
+
WITH RECURSIVE children AS (
1192
+
SELECT d.conceptidfrom, d.conceptidto, c2.value, c2.valueid as valueid, c.value as valueto, c.valueid as valueidto, c.valuetype as vtype, 1 AS depth, array[d.conceptidto] AS conceptpath, array[c.valueid] AS idpath ---|NonRecursive Part
1193
+
FROM relations d
1194
+
JOIN values c ON(c.conceptid = d.conceptidto)
1195
+
JOIN values c2 ON(c2.conceptid = d.conceptidfrom)
1196
+
WHERE d.conceptidfrom = %s
1197
+
and c2.valuetype = 'prefLabel'
1198
+
and c.valuetype in ('prefLabel', 'sortorder', 'collector')
1199
+
and (d.relationtype = 'member' or d.relationtype = 'hasTopConcept')
1200
+
UNION
1201
+
SELECT d.conceptidfrom, d.conceptidto, v2.value, v2.valueid as valueid, v.value as valueto, v.valueid as valueidto, v.valuetype as vtype, depth+1, (conceptpath || d.conceptidto), (idpath || v.valueid) ---|RecursivePart
1202
+
FROM relations d
1203
+
JOIN children b ON(b.conceptidto = d.conceptidfrom)
1204
+
JOIN values v ON(v.conceptid = d.conceptidto)
1205
+
JOIN values v2 ON(v2.conceptid = d.conceptidfrom)
1206
+
WHERE v2.valuetype = 'prefLabel'
1207
+
and v.valuetype in ('prefLabel','sortorder', 'collector')
1208
+
and (d.relationtype = 'member' or d.relationtype = 'hasTopConcept')
1209
+
) SELECT conceptidfrom::text, conceptidto::text, value, valueid::text, valueto, valueidto::text, depth, idpath::text, conceptpath::text, vtype FROM children ORDER BY depth, conceptpath;
0 commit comments