Hey team -
I've went through the docs, and likely because I'm a bit of a hack - I'm finding it hard to find my answers (because I'm not sure what I'm specifically looking to "do" other than "make it work")
So I have the following situation:
I have a GAME table (with a corresponding LANGUAGE table) - because my users might play games.
game_language_table = Table(
'game_language',
Base.metadata,
Column('game_id', UUID(as_uuid=True), ForeignKey('game.id'), primary_key=True, nullable=False),
Column('language_id', String(length=255), ForeignKey('language.id'), primary_key=True, nullable=False),
Column('name', String(length=255), nullable=False, unique=True))
game_table = Table(
'game',
Base.metadata,
Column('id', UUID(as_uuid=True), primary_key=True, nullable=False, default=sqlalchemy.text('uuid_generate_v4()'), server_default=sqlalchemy.text('uuid_generate_v4()')),
Column('join_code', String(length=8), nullable=False, unique=True))
I also have a ROUND table which is effectively just an extension of a game, but with a sequence number. Basically - if I have a collection of games that I want users to play - they play them as "Rounds" in a given order.
round_table = Table(
'round',
Base.metadata,
Column('id', UUID(as_uuid=True), primary_key=True, nullable=False, default=sqlalchemy.text('uuid_generate_v4()'), server_default=sqlalchemy.text('uuid_generate_v4()')),
Column('tournament_id', UUID(as_uuid=True), ForeignKey('tournament.id'), nullable=False),
Column('game_id', UUID(as_uuid=True), ForeignKey('game.id'), nullable=False),
Column('sequence', Integer, nullable=False, default=0),
UniqueConstraint('tournament_id', 'sequence'))
So my GAME table has an "id" field, and my round table has a game_id field, and an id field.
When I try to join(game_table, round_table) - I get the following error:
Implicitly combining column round.id with column game.id under attribute 'id'. Please configure one or more attributes for these same-named columns explicitly.So - because there's multiple points of entry into these tables: Editing a Game is a direct thing, editing a round (which also edits its underlying game) is also a direct thing.
How do I craft the JOIN so I don't step on toes?
I tried doing the following:
round_join = join(round_table, game_join.alias('game'))That didn't help, because game_id still squashes between game_language and round.
Is there a smarter way to go about this?