Re: [GENERAL] Ltree - how to sort nodes on parent node

2010-04-20 Thread Harald Fuchs
In article <1f96e061-713c-4929-a7d9-278e5b608...@solfertje.student.utwente.nl>, Alban Hertroys writes: > On 20 Apr 2010, at 18:05, Harald Fuchs wrote: >> Here's a working version: >> >> WITH RECURSIVE tree (path, category, sort_order, parent) AS ( >> SELECT category, category, sort_order::text,

Re: [GENERAL] Ltree - how to sort nodes on parent node

2010-04-20 Thread Peter Hunsberger
On Tue, Apr 20, 2010 at 1:58 PM, Alban Hertroys wrote: > On 20 Apr 2010, at 11:59, cojack wrote: > > >> I am not interested about recursive queries, i think this kill ltree idea. > > > And IMHO it should. ltree is from a time when we didn't have any other means > to describe data organised as a t

Re: [GENERAL] Ltree - how to sort nodes on parent node

2010-04-20 Thread Alban Hertroys
On 20 Apr 2010, at 11:59, cojack wrote: >> 1). The way you're doing this in your new examples should work, although >> I'd probably make the ordering numbers part of the category names and >> split those off when I read them. For example: >> 27 | 1|Top >> 28 | 1|Top.1|Science >>

Re: [GENERAL] Ltree - how to sort nodes on parent node

2010-04-20 Thread Alban Hertroys
On 20 Apr 2010, at 18:05, Harald Fuchs wrote: > Here's a working version: > > WITH RECURSIVE tree (path, category, sort_order, parent) AS ( >SELECT category, category, sort_order::text, parent >FROM node >WHERE parent IS NULL > UNION ALL >SELECT t.path || '.' || n.category, >

Re: [GENERAL] Ltree - how to sort nodes on parent node

2010-04-20 Thread Harald Fuchs
In article <59670b22-30cb-4e6e-83c8-c1d1036c9...@solfertje.student.utwente.nl>, Alban Hertroys writes: > 2). Drop the ltree column and go with a truly recursive approach, something > like this: > CREATE TABLE node ( > categorytextNOT NULL PRIMARY KEY, > sort_order i

Re: [GENERAL] Ltree - how to sort nodes on parent node

2010-04-20 Thread cojack
> Alban Hertroys wrote: > > > Aha, looks like you want to sort each tree level by some user-specified > order. > > You should realise that ltree was contributed before Postgres supported > (recursive) CTE's. If you're using ltree in combination with recursive > CTE's you're doing twice the work

Re: [GENERAL] Ltree - how to sort nodes on parent node

2010-04-20 Thread Alban Hertroys
On 19 Apr 2010, at 20:26, cojack wrote: >> Alban Hertroys wrote: >> >> It would help if you'd show us what result you expect from ordering the >> above. >> >> Most people would order this by path I think. However that doesn't match >> your sort column and I can't think of any method that would g

Re: [GENERAL] Ltree - how to sort nodes on parent node

2010-04-19 Thread cojack
> Alban Hertroys wrote: > > It would help if you'd show us what result you expect from ordering the > above. > > Most people would order this by path I think. However that doesn't match > your sort column and I can't think of any method that would give results > in such an arbitrary order as you s

Re: [GENERAL] Ltree - how to sort nodes on parent node

2010-04-19 Thread Alban Hertroys
On 19 Apr 2010, at 9:23, cojack wrote: > Hello, > id | path | sort > > +---+-- >