Hi all,

I know I'm probably missing something painfully obvious here, but here
goes anyway. I'm trying to create a table which has two foreign keys
to a different table, and failing miserably. I understand I'm supposed
to use the primaryjoin argument to relation… here's what I have in my
class definition:

    sender_id = sa.Column(sa.Integer, sa.ForeignKey(User.id),
nullable=False)
    sender = relation(User, backref=backref('feedback_sent'),
primaryjoin=(sender_id == User.id))
    recipient_id = sa.Column(sa.Integer, sa.ForeignKey(User.id),
nullable=False)
    recipient = relation(User, backref=backref('feedback_received'),
primaryjoin=(recipient_id == User.id))

Which seems to work okay, until I try to actually assign a sender or
recipient (with something like ClassInstance.sender = UserInstance),
when I will get error messages like "IntegrityError: (IntegrityError)
null value in column "sender_id" violates not-null constraint" (even
though [at least as far as I am concerned] the column is not empty).

I know when I find the answer to this I'm going to feel incredibly
ignorant! Any help would be much appreciated.

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