Skip to content
Discussion options

You must be logged in to vote

The problem turned out to be in my relationships in models. The SQLAlchemy docs helped me understand it (https://docs.sqlalchemy.org/en/13/orm/basic_relationships.html#one-to-one)

Essentially, in the Company mode, I had to add uselist=False in the relationship.

class Company(Base, ToDictMixin, TimestampMixin):
    __tablename__ = 'companies'

    number = Column(Integer, primary_key=True)
    name = Column(String)
    incorporated = Column(Date)

    address = relationship("Address", uselist=False, back_populates="occupier")

    def __repr__(self):
        return f"<Company(number='{self.number}', name='{self.name}', incorporated='{self.incorporated.isoformat}')>"

Marking as closed now.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem question-migrate
2 participants
Converted from issue

This discussion was converted from issue #1397 on February 28, 2023 09:55.