I have a table that has two columns that reference the same table in a
foreign-key relationship.  What do I need to specify and where to
avoid the error below?

<class 'sqlalchemy.exceptions.ArgumentError'>: Error determining
primary and/or secondary join for relationship 'FeatureLoc.feature
(Feature)'. If the underlying error cannot be corrected, you should
specify the 'primaryjoin' (and 'secondaryjoin', if there is an
association table present) keyword arguments to the relation()
function (or for backrefs, by specifying the backref using the
backref() function with keyword arguments) to explicitly specify the
join conditions. Nested error is "Can't determine join between
'featureloc' and 'feature'; tables have more than one foreign key
constraint relationship between them. Please specify the 'onclause' of
this join explicitly."

I am reflecting these tables from the database:

feature_t = Table('feature',metadata,autoload=True)
featureloc_t = Table('featureloc',metadata,autoload=True)

class Feature(object):
    pass

class FeatureLoc(object):
    pass

sqlalchemy.orm.mapper(Feature,feature_t,properties={
    'elements' : relation(Element,backref='feature')
    })
sqlalchemy.orm.mapper(FeatureLoc,featureloc_t,properties={
     'srcfeature' : relation(Feature),
     'feature'    : relation(Feature)
     })

Thanks,
Sean


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