Hello everyone!

I can't resolve my issue by myself, I really have no idea how to filter 
desired results, I've m2m relationships between User and Tournament models 
via table PlayerOfTournament, sometime I need to get User model which will 
include a list of all related tournaments except not active ones. My 
weakness is that I can't even to construct pure sql query :(


class Tournament(BaseMixin, TimeCreatedMixin, TimeUpdateMixin, IsActiveMixin
, Base):
    players = relationship('Player', back_populates='tournament')

class Player(TimeCreatedMixin, TimeUpdateMixin, Base):
    __tablename__ = 'playeroftournament'

    user_id = Column(UUID(as_uuid=True), ForeignKey('user.id', ondelete='
SET NULL'), primary_key=True)
    tournament_id = Column(UUID(as_uuid=True), ForeignKey('tournament.id', 
ondelete='SET NULL'), primary_key=True)

class User (BaseMixin,  IsActiveMixin, TimeCreatedMixin, TimeUpdateMixin, 
Base):
    member_of = relationship('Player', back_populates='user')

Could anyone to help with ORM query or sql statement?!

Many thanks in advance.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/70b27d25-6dbc-45ee-a292-6d4d2cf2dab0%40googlegroups.com.

Reply via email to