On Jun 9, 2008, at 10:50 AM, Paul Johnston wrote:

> Hi,
>
> I have had the following relation working ok for some time, but a  
> recent update of SQLAlchemy means it's now asking for a remote_side  
> argument. I'm really not too sure what too put in there - I've never  
> really understood that parameter, or foreign_keys.
>
> VulnResDesc.mapper.add_property('rawvulns',  
> sao.relation(VulnRes.mapper,
>     primaryjoin = sa.and_(VulnRes.targetid == VulnResDesc.targetid,
>                        VulnMap.vulndescid == VulnResDesc.id,
>                        VulnMap.tool == VulnRes.tool,
>                        VulnMap.toolvulnid == VulnRes.toolvulnid),
>     foreign_keys = [VulnResDesc.c.targetid, VulnResDesc.c.id],
>     viewonly = True,
>     uselist = True))



ultimately all relations distill the join condition into a set of  
pairs, above it would be:

[ (VulnResDesc.targetid, VulnRes.targetid) ]

i.e., the column pairs that are involved with the VulnResDesc and  
VulnRes mappers.  Column pairs that deal with "VulnMap" are not of any  
use to the relation() since we can't write to them, we cant use them  
as the source of newly generated foreign keys, and we can't compare to  
them in a lazy load.

So using foreign_keys which only deals with these columns should  
probably work by itself:

foreign_keys = [VulnResDesc.targetid]

The remote_side argument, if needed, would be remote_side=  
[VulnRes.targetid] since that is the "right" side of the relation.




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