fix: Add explicit primaryjoin to UserContainer relationships for SQLAlchemy ambiguity resolution
This commit is contained in:
parent
8a883ad886
commit
941b2c6001
11
models.py
11
models.py
|
|
@ -152,9 +152,14 @@ class UserContainer(db.Model):
|
||||||
blocked_at = db.Column(db.DateTime, nullable=True)
|
blocked_at = db.Column(db.DateTime, nullable=True)
|
||||||
blocked_by = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='SET NULL'), nullable=True)
|
blocked_by = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='SET NULL'), nullable=True)
|
||||||
|
|
||||||
# Relationships
|
# Relationships (explicit primaryjoin wegen mehrerer FKs zu User)
|
||||||
user = db.relationship('User', foreign_keys=['user_id'], back_populates='containers')
|
user = db.relationship('User',
|
||||||
blocker = db.relationship('User', foreign_keys=['blocked_by'])
|
foreign_keys=['user_id'],
|
||||||
|
primaryjoin='UserContainer.user_id==User.id',
|
||||||
|
back_populates='containers')
|
||||||
|
blocker = db.relationship('User',
|
||||||
|
foreign_keys=['blocked_by'],
|
||||||
|
primaryjoin='UserContainer.blocked_by==User.id')
|
||||||
|
|
||||||
# Unique: Ein User kann nur einen Container pro Typ haben
|
# Unique: Ein User kann nur einen Container pro Typ haben
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user