From c9f9b4e344b2f4eac1c9052c7130c1a859b930e0 Mon Sep 17 00:00:00 2001 From: "XPS\\Micro" Date: Sun, 8 Feb 2026 17:54:35 +0100 Subject: [PATCH] fix: Add explicit foreign_keys to User.containers relationship MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models.py b/models.py index 39900c7..42d083a 100644 --- a/models.py +++ b/models.py @@ -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