Michael, 

After some tweaking around, it works! Thanks for all your help, it was
invaluable! I'm sure I'll be back for more though... J

 

Doug

 

From: [email protected] [mailto:[EMAIL PROTECTED]
On Behalf Of Michael Bayer
Sent: Friday, September 26, 2008 5:50 PM
To: [email protected]
Subject: [sqlalchemy] Re: How to perform inner joins

 

 

On Sep 26, 2008, at 5:42 PM, Doug Farrell wrote:





I'm have the 'type' column in the press_routing_press linking table;
something like this:

 

Sess.query(Press,
PressRoutingPress.type).join(Press.routes).filter(PressRouting.code=='A'
).all()

 

I've tried some variations of this, but no luck. I've also tried
applying what the documentation says about using the Association Object,
but haven't figured it out yet. I've gotten back lots of data, just not
the limited set I'm looking fore.

 

oh.  This is a different situation.  You have press_routing_press mapped
to its own class, and it has columns that contain information distinct
from the join between Press and PressRouting.   You'd have to join that
instead.  If you have a relation on Press for it, its easy:

 

query(Press, PressRoutingPress.type).join(Press.pressrouting,
PressRoutingPress.route).filter(...)...

 

you should also set "viewonly=True" on your Press.routes relation(),
otherwise during flush you could have conflicting data placed in the
press_routing_press table.

 

The preferred pattern for an association table that has additonal
columns in it is the "association object pattern", which can be used in
conjunction with the "associationproxy" to simplify operations from
Press->PressRouting.   But in your case I'd just use straight
association object for starters.   This pattern is described in the
mapping docs.

 

 



 


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to