Last active
December 26, 2015 18:59
-
-
Save rclark72/7198432 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What I have | |
following = db.relationship('User', | |
secondary=UserFollowing.__table__, | |
primaryjoin='User.id==UserFollowing.user1_id', | |
secondaryjoin='User.id==UserFollowing.user2_id', | |
foreign_keys=[UserFollowing.user1_id, UserFollowing.user2_id], | |
lazy='joined') | |
# What I want | |
following = db.relationship('User', | |
secondary=UserFollowing.__table__, | |
primaryjoin='and_(User.id==UserFollowing.user1_id, remote(User.id==UserFollowing.user1_id))', | |
foreign_keys='[UserFollowing.user1_id]', | |
lazy='joined') | |
# Error: | |
# InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Original exception was: Relationship User.following could not determine any unambiguous local/remote column pairs based on join condition and remote_side arguments. Consider using the remote() annotation to accurately mark those elements of the join condition that are on the remote side of the relationship. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment