[sqlalchemy] pyodbc/{SQL SERVER} producing invalid query

2013-10-19 Thread aephie1a
Hi SQLAlchemy 0.8.2, Win32, Microsoft "SQL Server" ODBC Driver Briefly... class Uno(Base): __tablename__ = 'UNO' __table_args__ = { 'autoload':True, 'autoload_with':engine } duos = relationship("DuoDuo",backref=backref("duos")) print session.query(Uno, Uno.du

Re: [sqlalchemy] newest address for each user

2013-10-19 Thread Michael Bayer
On Oct 19, 2013, at 4:24 PM, Sebastian Elsner wrote: > Hello, > > using the Address and User example, where the Address is connected to > the User via a many-to-many relationship, I want to get all users with > the date of their newest address. This is what I have now: > > s.query(User, s.quer

[sqlalchemy] newest address for each user

2013-10-19 Thread Sebastian Elsner
Hello, using the Address and User example, where the Address is connected to the User via a many-to-many relationship, I want to get all users with the date of their newest address. This is what I have now: s.query(User, s.query(func.max(Address.created)).\ filter(Address.users.any()).correlate(U