Hi,
I have the following property on an object, which is working fine:
class VulnResDesc:
...
@property
def rawvulns(self):
return VulnRes.select(
and_(VulnRes.c.targetid == self.targetid,
VulnMap.c.tool == VulnRes.c.tool,
VulnMap.c.toolvulnid == VulnRes.c.toolvulnid,
VulnMap.c.vulndescid == self.id))
The role of VulnMap is a bit funky in the query, but this is intentional.
Now, I am trying to code this as a relation instead of a property, the
following is what I've got so far:
VulnResDesc.mapper.add_property('rawvulns', relation(VulnRes.mapper,
primaryjoin = and_(VulnRes.c.targetid == VulnResDesc.c.targetid,
VulnMap.c.vulndescid == VulnResDesc.c.id,
VulnMap.c.tool == VulnRes.c.tool,
VulnMap.c.toolvulnid == VulnRes.c.toolvulnid),
foreign_keys = [VulnResDesc.c.targetid, VulnResDesc.c.id]))
This almost works, but it returns a single object, which I was expecting a
list. Any ideas what's up?
BTW, the reason I want to recode this is I'm hoping to use the eagerloader.
Still, to start with I'll settle for just getting it to work lazily :-)
Paul
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---