Simon Bruder
8eb59dd7c7
This can be seen as partially reverting
e83bc8316e
, which moved everything to the
place where it was used.
75 lines
2.9 KiB
JSON
75 lines
2.9 KiB
JSON
{
|
|
"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 ALL\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 item_states.state AS \"state!: ItemState\"\n FROM cte\n JOIN items\n ON cte.id = items.id\n JOIN item_classes\n ON items.class = item_classes.id\n JOIN item_states\n ON items.id = item_states.item\n ORDER BY items.created_at\n ",
|
|
"describe": {
|
|
"columns": [
|
|
{
|
|
"ordinal": 0,
|
|
"name": "id!",
|
|
"type_info": "Uuid"
|
|
},
|
|
{
|
|
"ordinal": 1,
|
|
"name": "name",
|
|
"type_info": "Varchar"
|
|
},
|
|
{
|
|
"ordinal": 2,
|
|
"name": "class",
|
|
"type_info": "Uuid"
|
|
},
|
|
{
|
|
"ordinal": 3,
|
|
"name": "class_name",
|
|
"type_info": "Varchar"
|
|
},
|
|
{
|
|
"ordinal": 4,
|
|
"name": "parents!",
|
|
"type_info": "UuidArray"
|
|
},
|
|
{
|
|
"ordinal": 5,
|
|
"name": "parent_names!: Vec<Option<String>>",
|
|
"type_info": "VarcharArray"
|
|
},
|
|
{
|
|
"ordinal": 6,
|
|
"name": "parent_class_names!",
|
|
"type_info": "VarcharArray"
|
|
},
|
|
{
|
|
"ordinal": 7,
|
|
"name": "state!: ItemState",
|
|
"type_info": {
|
|
"Custom": {
|
|
"name": "item_state",
|
|
"kind": {
|
|
"Enum": [
|
|
"borrowed",
|
|
"inactive",
|
|
"loaned",
|
|
"owned"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"parameters": {
|
|
"Left": []
|
|
},
|
|
"nullable": [
|
|
null,
|
|
true,
|
|
false,
|
|
false,
|
|
null,
|
|
null,
|
|
null,
|
|
true
|
|
]
|
|
},
|
|
"hash": "cdb1777fdc044c9b34e82dde93e429177ea5af957398553046590aedd0f4040b"
|
|
}
|