Try this:

mapper(Parent, parent_table, properties = {
              'boys':relation(Child, backref='parent', 
primaryjoin=(and_(child_table.c.pid=parent_table.c.id, 
child_table.c.gb=='b'),
              'girls':relation(Child, backref='parent', 
primaryjoin=(and_(child_table.c.pid=parent_table.c.id, 
child_table.c.gb=='g')
              })

Mike Conley wrote:
> How do I create a relation that filters the list property when 
> accessing the data?
>
> class Parent(Base):
>     __tablename__ = 'parent'
>     id = Column(Integer, primary_key=True)
>     name = Column(String)
>
> class Child(Base):
>     __tablename__ = 'child'
>     id = Column(Integer, primary_key=True)
>     pid = Column(Integer, ForeignKey('parent.id <http://parent.id>'))
>     name = Column(String)
>     bg = Column(String)  # b=boy, g=girl
>
> Parent.children = relation(Child, backref='parent')
>
> Gives me a relation that can be used to get a list of all children
>
>
>
>
> Question is how to specify a relation that gives a list of the boys
>
> Parent.boys = relation(Child, ??????????????????)
>
> I suspect it is something pretty straight forward, but can't figure it out
>
> -- 
> Mike Conley
>
>
> >


-- 
David Gardner
Pipeline Tools Programmer, "Sid the Science Kid"
Jim Henson Creature Shop
dgard...@creatureshop.com


--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to