On May 27, 2013, at 5:16 AM, Alexey Vihorev <[email protected]> wrote:
> Hi!
>
> Can I handle this situation properly, if at all?
>
> Base = declarative_base()
>
> class Person(Base):
> __tablename__ = 'persons'
> id = Column(Integer, primary_key=True)
> best_friend_id = Column(Integer, ForeignKey('persons.id'))
> best_friend = relationship('Person', remote_side = 'Person.id')
>
> Base.metadata.create_all(sa_engine)
>
> person = Person()
> person.best_friend = person #<<< problematic self-reference
> s.add(person)
> s.commit() #sqlalchemy.exc.CircularDependencyError: Circular dependency
> detected.
it will work with post_update
class Person(Base):
__tablename__ = 'persons'
id = Column(Integer, primary_key=True)
best_friend_id = Column(Integer, ForeignKey('persons.id'))
best_friend = relationship('Person', remote_side = 'Person.id',
post_update=True)
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
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 http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.