Hello, I have a question regarding using a mapper to add a relation to a mapped class using instance attributes (not contained in the mapped classes table def) on the mapped class control the select statement for the join.
For example: my Calendar class has a relation to CalendarEvent Calendar.map_table(calendar_table, properties={'events':relation(CalendarEvent,backref='calendar',collection_class = CalendarEventList)}) I would like to be able to control the where clause of the join the mapper uses when the property is accessed with data from my Calendar class that is not in the table definition, such as the time slice the Calendar represents. So something like: Calendar.map_table(calendar_table, properties={'events':relation(CalendarEvent,primaryjoin=and_(Calendar.c.id==CalendarEvent.c.calendar_id, calendar.CalendarEvent.c.starttime >= ???{need help}???)),backref='calendar',collection_class = CalendarEventList)}) so in a use case: c = Calendar() [Assume fill from db] c.event_list_start = datetime.now() c.event_list_end = datetime.now() + timedelta(days=1) and the mapper would have: Calendar.map_table(calendar_table,properties={'events':relation(CalendarEvent, primaryjoin=and_( Calendar.c.space_id==calendar.CalendarEvent.c.calendar_id, CalendarEvent.c.starttime >= Calendar.event_list_start, CalendarEvent.c.endtime <= Calendar.event_list_end, )),backref='calendar',collection_class = CalendarEventList)}) I am not sure if SQLalchemy supports this or if I am looking at this the wrong way. Thanks in advance, Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---