On Friday 31 July 2009 10:19:29 am Michael Bayer wrote:
> BillingInfo.__table__. BillingInfo is a python class, billing_table is
> the Table object.
After all that, it turned out that yet *another* table needed to be linked in.
Here's what I finally ended up with:
class Invoice(Base):
BillingInfo = relation('BillingInfo',
primaryjoin=''.join("""
and_(Invoice.pay2addrid==BillingInfo.pay2addrid,
Invoice.customer==Customer.customer,
Customer.xrscustid==BillingInfo.xrscustid,
Invoice.shipid==Ship.shipid,
or_(and_(Ship.typeship=='BOL',BillingInfo.typeship=='GBL'),
and_(Ship.typeship!='BOL',BillingInfo.typeship==Ship.typeship))
)
""".split('\n')))
This works, always returns the right values, and is eagerload-friendly.
Thanks again for pointing me in the right direction! Even if this is quite a
bit of upfront work, I've already saved screenfuls of SQL by converting to SA.
--
Kirk Strauser
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---