Compare commits
4 commits
35230b6c37
...
1d831585bd
Author | SHA1 | Date | |
---|---|---|---|
Simon Bruder | 1d831585bd | ||
Simon Bruder | a72d5b40e2 | ||
Simon Bruder | 1f6298af4a | ||
Simon Bruder | 5b3dd34312 |
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n WITH RECURSIVE cte AS (\n SELECT\n id,\n ARRAY[]::UUID[] AS parents,\n ARRAY[]::VARCHAR[] AS parent_names,\n ARRAY[]::VARCHAR[] AS parent_class_names\n FROM items\n WHERE parent IS NULL\n\n UNION\n\n SELECT\n items.id,\n cte.parents || items.parent,\n cte.parent_names || parent.name,\n cte.parent_class_names || parent_class.name\n FROM cte\n JOIN items\n ON items.parent = cte.id\n JOIN items AS \"parent\"\n ON parent.id = cte.id\n JOIN item_classes AS \"parent_class\"\n ON parent.class = parent_class.id\n )\n SELECT\n cte.id AS \"id!\",\n items.name,\n items.class,\n item_classes.name AS \"class_name\",\n cte.parents AS \"parents!\",\n cte.parent_names AS \"parent_names!: Vec<Option<String>>\",\n cte.parent_class_names AS \"parent_class_names!\"\n FROM cte\n JOIN items\n ON cte.id = items.id\n JOIN item_classes\n ON items.class = item_classes.id\n ORDER BY items.created_at\n ",
|
||||
"query": "\n WITH RECURSIVE cte AS (\n SELECT\n id,\n ARRAY[]::UUID[] AS parents,\n ARRAY[]::VARCHAR[] AS parent_names,\n ARRAY[]::VARCHAR[] AS parent_class_names\n FROM items\n WHERE parent IS NULL\n\n UNION\n\n SELECT\n items.id,\n cte.parents || items.parent,\n cte.parent_names || items.name,\n cte.parent_class_names || item_classes.name\n FROM items\n JOIN cte\n ON items.parent = cte.id\n JOIN item_classes\n ON items.class = item_classes.id\n )\n SELECT\n cte.id AS \"id!\",\n items.name,\n items.class,\n item_classes.name AS \"class_name\",\n cte.parents AS \"parents!\",\n cte.parent_names AS \"parent_names!: Vec<Option<String>>\",\n cte.parent_class_names AS \"parent_class_names!\"\n FROM cte\n JOIN items\n ON cte.id = items.id\n JOIN item_classes\n ON items.class = item_classes.id\n ORDER BY items.created_at\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
@ -52,5 +52,5 @@
|
|||
null
|
||||
]
|
||||
},
|
||||
"hash": "3dedb7b184103c1d418f7b94e26c75aea0c7d22e009299d1b87443e350578171"
|
||||
"hash": "5dac9aa215abdc07cda1f4d46db4bcafec45b6264efcb8a175580a71e48c7421"
|
||||
}
|
|
@ -44,15 +44,13 @@ async fn get(pool: web::Data<PgPool>, user: Identity) -> actix_web::Result<impl
|
|||
SELECT
|
||||
items.id,
|
||||
cte.parents || items.parent,
|
||||
cte.parent_names || parent.name,
|
||||
cte.parent_class_names || parent_class.name
|
||||
FROM cte
|
||||
JOIN items
|
||||
cte.parent_names || items.name,
|
||||
cte.parent_class_names || item_classes.name
|
||||
FROM items
|
||||
JOIN cte
|
||||
ON items.parent = cte.id
|
||||
JOIN items AS "parent"
|
||||
ON parent.id = cte.id
|
||||
JOIN item_classes AS "parent_class"
|
||||
ON parent.class = parent_class.id
|
||||
JOIN item_classes
|
||||
ON items.class = item_classes.id
|
||||
)
|
||||
SELECT
|
||||
cte.id AS "id!",
|
||||
|
|
Loading…
Reference in a new issue