ah, it has to be other way around unit = session.query(Unit).filter(Unit.id==3).first() rec = sess.query( Record).filter( Record.theunit == unit)... where theuint is the backref of Unit.records.
see http://www.sqlalchemy.org/docs/05/ormtutorial.html#common-relation-operators or just wait for Mike (-:) ciao svil svilendobrev.com http://www.linkedin.com/in/svilendobrev On Friday 13 February 2009 10:30:24 Chris Withers wrote: > a...@svilendobrev.com wrote: > > use the relation as a join path, and then whatever > > filtering/ordering.... > > > > try: > > unit.join(Unit.records).order_by(Record.date.desc()).first() > > or > > unit.join('records').order_by(Record.date.desc()).first() > > That gives me: > > AttributeError: 'Unit' object has no attribute 'join' > > cheers, > > Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---