{
_ => [
'tree_table', -join => {
as => 'tree',
on => { 'tree.id' => 'tree_with_path.id' },
to => { -select => {
from => 'tree_with_path',
select => '*',
with_recursive => [
[ 'tree_with_path', 'id', 'parent_id', 'path' ], { -select => {
_ => [
'id', 'parent_id', { -as =>
[
{ -cast => { -as => [ 'id', 'char', 255 ] } },
'path',
]
},
],
from => 'tree_table',
union_all => { -select => {
_ => [
't.id', 't.parent_id', { -as => [
{ -concat => [ 'r.path', \"'/'", 't.id' ] },
'path',
] },
],
from => [
'tree_table', -as => 't', -join => {
as => 'r',
on => { 't.parent_id' => 'r.id' },
to => 'tree_with_path',
},
],
} },
where => { parent_id => undef },
} },
],
} },
},
],
set => { path => { -ident => [ 'tree', 'path' ] } },
}