33 lines
1.9 KiB
JSON
33 lines
1.9 KiB
JSON
|
{
|
||
|
"db_name": "PostgreSQL",
|
||
|
"query": "WITH RECURSIVE item_class_children AS (\n SELECT\n item_classes.id,\n array_remove(array_agg(children.id), NULL) AS \"children\"\n FROM item_classes\n LEFT JOIN item_classes AS \"children\"\n ON item_classes.id = children.parent\n GROUP BY item_classes.id\n ),\n cte AS (\n SELECT\n item_classes.id,\n item_classes.name,\n item_class_children.children\n FROM item_classes\n JOIN item_class_children\n ON item_classes.id = item_class_children.id\n WHERE item_class_children.children = '{}'\n\n UNION\n\n SELECT\n item_classes.id,\n item_classes.name,\n item_class_children.children\n FROM item_classes\n JOIN item_class_children\n ON item_classes.id = item_class_children.id\n JOIN cte\n ON cte.id = ANY (item_class_children.children)\n )\n SELECT\n id AS \"id!\",\n name AS \"name!\",\n children AS \"children!\"\n FROM cte",
|
||
|
"describe": {
|
||
|
"columns": [
|
||
|
{
|
||
|
"ordinal": 0,
|
||
|
"name": "id!",
|
||
|
"type_info": "Uuid"
|
||
|
},
|
||
|
{
|
||
|
"ordinal": 1,
|
||
|
"name": "name!",
|
||
|
"type_info": "Varchar"
|
||
|
},
|
||
|
{
|
||
|
"ordinal": 2,
|
||
|
"name": "children!",
|
||
|
"type_info": "UuidArray"
|
||
|
}
|
||
|
],
|
||
|
"parameters": {
|
||
|
"Left": []
|
||
|
},
|
||
|
"nullable": [
|
||
|
null,
|
||
|
null,
|
||
|
null
|
||
|
]
|
||
|
},
|
||
|
"hash": "3eecdd98e2f76979a79883a8946e05977c45058536561e5752269d5933e271da"
|
||
|
}
|