add passive_deletes = True
sandro dentella wrote:
>
> Hi,
>
> I have a simple setup that may be summarized as:
>
> class User(Base):
> __tablename__ = 'user'
> name = Column(String(20), primary_key=True)
>
> class Mail(Base):
> __tablename__ = 'address'
> mail = Column(String(20), primary_key=True)
> user_name = Column(ForeignKey(User.name, ondelete="CASCADE"),
> nullable=False)
>
>
> the generated DDL allows deletion of a user also in case it has
> associated
> addresses thanks to the ON DELETE CASCADE.
>
> If I try to delete the object from sqlalchemy I get an error, since SA
> tries
> to set úser_name'attribute to NULL that is forbidden by the NOT NULL
> constraint.
>
>
> I can add a relation that will fix things by adding a backref:
>
> user = relation(User,
> backref=backref('addresses', cascade='all, delete-
> orphan'))
>
> Is there a way to obtain that any cascading is left to the backend?
> (pg in
> my case). I have not been able to find references but I'm sure I saw
> some
> discussion on that already...
>
>
> Thanks in advance
>
> sandro
> *:-)
>
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---