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 sqlalchemy@googlegroups.com
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