On 2/13/2014 11:04 AM, Michael Bayer wrote:
On Feb 13, 2014, at 11:53 AM, Michael Hipp <mich...@redmule.com> wrote:

I don't see a "first_owner" relationship defined above, so the above example is not complete. The approach using "foreign_keys" is the correct approach to resolving ambiguity in join conditions, however. If the documented approach is not working you'd need to provide a succinct self-contained example I can run.

Sorry, it was tripping over a different error, here's the code with extras removed (I think!):

class Animal(Base):
    __tablename__ = 'animals'
    id_ = Column(Integer, primary_key=True)

    sire_id = Column(Integer, ForeignKey('animals.id_'))
    dam_id = Column(Integer, ForeignKey('animals.id_'))

    sire = relationship('Animal', foreign_keys=[sire_id])
    dam = relationship('Animal', foreign_keys=[dam_id])
    children = relationship('Animal', foreign_keys=[sire_id, dam_id])

Gives:
sqlalchemy.exc.AmbiguousForeignKeysError: Could not determine join condition between parent/child tables on relationship Animal.children - there are multiple foreign key paths linking the tables. Specify the 'foreign_keys' argument, providing a list of those columns which should be counted as containing a foreign key reference to the parent table.

Thanks for any help,
Michael

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to