Hi everyone!
I can't solve my issue by myself, could anyone has advice on this.
I've models (simplified):
class Tournament(Base):
id = Column(UUID(as_uuid=True), primary_key=True)
owner_id = Column(UUID(as_uuid=True), ForeignKey('user.id', ondelete='
CASCADE'), nullable=False)
owner = relationship('User', back_populates='ownership', cascade='all,delete
')
players = relationship('PlayerOfTournament', back_populates='tournament',
cascade='all,delete')
class PlayerOfTournament(Base):
__tablename__ = 'playeroftournament'
user_id = Column(UUID(as_uuid=True), ForeignKey('user.id', ondelete='CASCADE
'), primary_key=True)
tournament_id = Column(UUID(as_uuid=True), ForeignKey('tournament.id',
ondelete='CASCADE'), primary_key=True)
user = relationship('User', back_populates='member_of', uselist=False,
cascade='all,delete')
tournament = relationship('Tournament', back_populates='players', uselist=
False, cascade='all,delete')
rank = Column(Integer)
class User(Base):
id = Column(UUID(as_uuid=True), primary_key=True)
ownership = relationship('Tournament', back_populates='owner', cascade='
all,delete')
member_of = relationship('PlayerOfTournament', back_populates='user', cscade
='all,delete')
username = Column(String(96))
I would to get all tournaments, with filter by some_user not in players.
I've no idea how construct query, I tried something like
session.query(Tournament).filter(Tournament.players.user.notin_(user.id)),
but it doesn't work.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/cd114cb7-788d-48b5-85e5-dc90962d06a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.