On Oct 19, 2013, at 11:17 PM, aephi...@gmail.com wrote: > 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.duos).all() > > sqlalchemy gets it wrong: > > SELECT [DUO_DUO].[ID] = [UNO].[DUO_DUO] AS duos > FROM [DUO_DUO], [UNO]
at the moment a relationship() can't reliably be used as an expression in query(), there's a ticket to enhance this functionality at http://www.sqlalchemy.org/trac/ticket/2846. Based on what it seems like the intent here is, I think you want: session.query(Uno, Duo).join(Uno.duos).all() Also you probably want to specify table name as lowercase "uno", the uppercase "UNO" indicates to SQLAlchemy a case-sensitive name which will be quoted as uppercase exactly, unless the schema were actually created with quoted uppercase names.
signature.asc
Description: Message signed with OpenPGP using GPGMail