I believe that I asked Michael a similar question, in a different way,
a few days ago.
The answer was to use "contains_eager". I used something like the
following and it worked great to query what the membership of a group
was at a specific time. The two tables remain simple, related by a
group_id and the query is dynamic according to the time that you are
interested in
map = mapper( Group,
group_table,
properties=dict( members=relation( Member,
backref='group' ) )
)
statement = names.outerjoin(members).select(
and_( Member.start <= reftime, Member.stop >= reftime
).apply_labels()
query = session.query(Group).options( contains_eager
('members') )
query = query.from_statement(statement)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---