I have an adjacency table setup similar to this example:
http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/examples/adjacencytree/basic_tree.py

However I am distinguishing between nodes and leaves. So I have my 
Node() and  Leaf(Node) classes setup, and I am currently mapping them 
against queries instead of tables, so I something like:

qry_node = select ([node_table], node_table.c.type!='file').alias 
('node_query')
qry_leaf = select ([node_table], node_table.c.type=='file').alias 
('leaf_query')

mapper(Leaf, qry_leaf...
mapper(Node, qry_node...

My question is that in some cases I need to treat leafs as if they were 
nodes, but in other cases I do not. So I was wondering if it is safe to 
mix/match using tables an queries like:

mapper(Node, node_table, properties = {
    ...
    'Parent' : relation(Node, remote_side=[qry_node]),
    'Children' : relation(Node, cascade='all', 
collection_class=attribute_mapped_collection('name')) })
    'Files' : relation(Leaf, 
primaryjoin=(node_table.c.uid==qry_leaf.c.parentuid),
                          order_by=qry_leaf.c.name, cascade='all, 
delete-orphan'),
    ...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to