From 8a883ad8867a11faadf2b24b2d013cd681510736 Mon Sep 17 00:00:00 2001 From: "XPS\\Micro" Date: Sun, 8 Feb 2026 18:33:48 +0100 Subject: [PATCH] fix: Add explicit primaryjoin to User.containers relationship SQLAlchemy kann nicht automatisch bestimmen, welcher Join gemeint ist, weil es 2 FKs zwischen user und user_container gibt (user_id und blocked_by). --- models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/models.py b/models.py index e690c37..95eafcb 100644 --- a/models.py +++ b/models.py @@ -37,8 +37,12 @@ class User(UserMixin, db.Model): # Beziehung fuer blocked_by blocker = db.relationship('User', remote_side=[id], foreign_keys=[blocked_by]) - # Multi-Container Support - containers = db.relationship('UserContainer', foreign_keys='UserContainer.user_id', back_populates='user', cascade='all, delete-orphan') + # Multi-Container Support (explicit primaryjoin wegen mehrerer FKs zu User) + containers = db.relationship('UserContainer', + foreign_keys='UserContainer.user_id', + primaryjoin='User.id==UserContainer.user_id', + back_populates='user', + cascade='all, delete-orphan') @property def container_id(self):