71
71
),
72
72
ancestors AS (
73
73
SELECT ascii_id,
74
- replace(replace(substr(fullkey, 3 ), ' .' , ' /' ), ' ^#^' , ' .' ) || ' /' AS asc_path
74
+ replace(replace(substr(fullkey, 3 ), ' .' , ' /' ), ' ^#^' , ' .' ) || ' /' AS asc_path,
75
+ replace(" key" , ' ^#^' , ' .' ) AS asc_name
75
76
FROM
76
77
json_prefixes AS jp,
77
78
json_tree(replace(jp .prefix_json , ' .' , ' ^#^' )) AS prefixes
@@ -84,14 +85,14 @@ Blocks *json_nodes* through *tops* constitute the same prologue as [before](sele
84
85
85
86
** Output**
86
87
87
- | ascii_id | asc_path |
88
- | ----------| ---------------------------|
89
- | 0FDAF2C8 | tcl/ |
90
- | 0FDAF2C8 | tcl/compat/ |
91
- | BE0A8514 | tcl/ |
92
- | BE0A8514 | tcl/pkgs/ |
93
- | BE0A8514 | tcl/pkgs/thread2.8.7/ |
94
- | BE0A8514 | tcl/pkgs/thread2.8.7/tcl/ |
88
+ | ascii_id | asc_name | asc_path |
89
+ | ----------| -------------| ------------- --------------|
90
+ | 0FDAF2C8 | tcl | tcl / |
91
+ | 0FDAF2C8 | compat | tcl/compat/ |
92
+ | BE0A8514 | tcl | tcl / |
93
+ | BE0A8514 | pkgs | tcl/pkgs/ |
94
+ | BE0A8514 | thread2.8.7 | tcl/pkgs/thread2.8.7/ |
95
+ | BE0A8514 | tcl | tcl /pkgs/thread2.8.7/tcl/ |
95
96
96
97
---
97
98
@@ -118,14 +119,13 @@ WITH
118
119
FROM levels
119
120
),
120
121
ancestors AS (
121
- SELECT min (jo .id ) AS id,
122
- replace(replace(substr(fullkey, 3 ), ' .' , ' /' ), ' ^#^' , ' .' ) || ' /' AS asc_path
122
+ SELECT jo .id ,
123
+ replace(replace(substr(fullkey, 3 ), ' .' , ' /' ), ' ^#^' , ' .' ) || ' /' AS asc_path,
124
+ replace(" key" , ' ^#^' , ' .' ) AS asc_name
123
125
FROM
124
126
json_objs AS jo,
125
127
json_tree(replace(jo .json_obj , ' .' , ' ^#^' )) AS terms
126
128
WHERE terms .parent IS NOT NULL
127
- GROUP BY asc_path
128
- ORDER BY id, asc_path
129
129
)
130
130
SELECT * FROM ancestors;
131
131
~~~
@@ -134,13 +134,13 @@ This query splits paths as provided and no longer accesses the *categories* tabl
134
134
135
135
** Output**
136
136
137
- | id | asc_path |
138
- | ----| ----------------------------------|
139
- | 1 | tcl/ |
140
- | 1 | tcl/compat/ |
141
- | 1 | tcl/compat/zlib1/ |
142
- | 2 | tcl/pkgs/ |
143
- | 2 | tcl/pkgs/thread2.8.7/ |
144
- | 2 | tcl/pkgs/thread2.8.7/tcl/ |
145
- | 2 | tcl/pkgs/thread2.8.7/tcl/cmdsrv/ |
146
-
137
+ | id | asc_name | asc_path |
138
+ | ----| -------------| ------------- ---------------------|
139
+ | 1 | tcl | tcl / |
140
+ | 1 | compat | tcl/compat/ |
141
+ | 1 | zlib1 | tcl/compat/zlib1/ |
142
+ | 2 | tcl | tcl/ |
143
+ | 2 | pkgs | tcl/pkgs/ |
144
+ | 2 | thread2.8.7 | tcl/pkgs/thread2.8.7/ |
145
+ | 2 | tcl | tcl /pkgs/thread2.8.7/tcl/ |
146
+ | 2 | cmdsrv | tcl/pkgs/thread2.8.7/tcl/cmdsrv/ |
0 commit comments