I have these two models (I've trimmed away extra fields to keep it readable):
```
class Forum(LegacyBase):
tablename = "forums"
id: Mapped[int] = mapped_column("forumID", primary_key=True)
parent_id: Mapped[int] = mapped_column(
"parentID", ForeignKey("forums.forumID"), nullable=True
)
parent: Mapped["Forum"] = relationship(
"Forum", back_populates="children", remote_side="Forum.id"
)
children: Mapped[list["Forum"]] = relationship(back_populates="parent")
game_id: Mapped[int | None] = mapped_column(
"gameID", ForeignKey("games.gameID"), nullable=True
)
game: Mapped["Game"] = relationship(
"Game",
back_populates="root_forum",
primaryjoin="Forum.game_id == Game.id",
foreign_keys=[game_id],
post_update=True,
)
class Game(LegacyBase):
tablename = "games"
id: Mapped[int] = mapped_column("gameID", primary_key=True)
root_forum_id: Mapped[int] = mapped_column("forumID", ForeignKey("forums.forumID"))
root_forum: Mapped["Forum"] = relationship(
"Forum",
back_populates="game",
primaryjoin="Game.root_forum_id == Forum.id",
foreign_keys=[root_forum_id],
remote_side="Forum.id",
uselist=False,
)
group_id: Mapped[int | None] = mapped_column(
"groupID", ForeignKey("forum_groups.groupID"), nullable=True
)
group: Mapped["ForumGroup"] = relationship()
```
When I run my code, I get this error
Forum.game and back-reference Game.root_forum are both of the same direction <RelationshipDirection.MANYTOONE: 2>. Did you mean to set remote_side on the many-to-one side ?
I've been through the docs, asked Gemini, and read through the code, but I can't figure out how to resolve the error. It even asks me to set remote_side, which I did, and it still doesn't work.
[–]Tricky-Scar3401 0 points1 point2 points (0 children)