fix: Add explicit foreign_keys to User.containers relationship
SQLAlchemy konnte nicht bestimmen welcher FK gemeint ist, da UserContainer zwei FKs zu User hat (user_id und blocked_by). Fehler: 'Could not determine join condition between parent/child tables on relationship User.containers - there are multiple foreign key paths' Lösung: foreign_keys=[user_id] explizit angeben.
This commit is contained in:
parent
d118bb9135
commit
c9f9b4e344
|
|
@ -149,7 +149,7 @@ class UserContainer(db.Model):
|
|||
blocked_by = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='SET NULL'), nullable=True)
|
||||
|
||||
# Relationships
|
||||
user = db.relationship('User', back_populates='containers')
|
||||
user = db.relationship('User', foreign_keys=[user_id], back_populates='containers')
|
||||
blocker = db.relationship('User', foreign_keys=[blocked_by])
|
||||
|
||||
# Unique: Ein User kann nur einen Container pro Typ haben
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user