On Jan 18, 2009, at 2:16 PM, Adam Dziendziel wrote:
> > On 18 Sty, 19:47, Michael Bayer <[email protected]> wrote: > >> However what I cant figure out with nested sets is, how do I load >> only >> the immediate children of a node ? That is the most common >> accessor >> I'd like on a self referential node and I'm not aware of how to do >> it. It makes it sort of impossible for there to be a ".children" >> accessor on a node, unless you load the full subtree and organize. > > It is possible if you add a 'depth' column which holds the absolute > distance of the node from the tree root. > Then, in order to load immediate children of a node, we can make a > query: > > SELECT * FROM nodes WHERE lft > node.lft and rgt < node.rgt and > depth=node.depth+1 yeah, the example is actually illustrating depth query based on a count at the end so we use that using HAVING, but here I see you actually added depth to the table. so we might add examples for both methods. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
