> -----Original Message----- > From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] > On Behalf Of Michael Bayer > Sent: 05 April 2011 18:38 > To: sqlalchemy@googlegroups.com > Subject: Re: [sqlalchemy] Two Objects, One Table and the inverse > > > On Apr 5, 2011, at 12:30 PM, Israel Ben Guilherme Fonseca wrote: > > > Thks for the insight Michael. > > With the @property solution, its not possible to make queries > like session.query(Person).filter(Person.address.street="Something") > right? > > > that's not possible with standard SQLAlchemy expression constructs > anyway. Normally you'd use Address.street to get clause elements > against Address. You can use hybrids to create this effect fully > (see http://www.sqlalchemy.org/docs/07/orm/extensions/hybrid.html ) >
Out of interest, if Person and Address were standard mapped classes with a one-to-one relationship between them, could that query be made to work: session.query(Person).filter(Person.address.street=="Something") I guess it would have to be equal to: session.query(Person).join(Person.address).filter(Address.street=="Somet hing") In order for that to work, Person.address would have to be a smart wrapper for the Address class that adds the join condition into any attribute comparison operations. Good idea, or silly idea? (Or perhaps it already works...) Simon -- 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.