Thanks Alex. However, the setup script raises an exception when the 'all,delete-orphan' directive is specified. Hence, this seems to be a no-go.
In addition, I've had some trouble with transaction rollbacks. Thus increasing the chances of DB inconsistency. On Sep 17, 5:22 am, alex bodnaru <[email protected]> wrote: > hello ozwyzard, > > On 09/17/2010 05:21 AM, ozwyzard wrote: > > > Configuration: TG2, MySQL, SQLAlchemy > > > The tg_user_group table uses onupdate='CASCADE', ondelete='CASCADE', > > and it is functional (when I delete a user, the associated entry in > > tg_user_group is deleted. > > > However, when I use ondelete='CASCADE' from within a DeclarativeBase > > class as follows: > > > class ABC(DeclarativeBase): > > __tablename__ = 'abc' > > id = Column(Integer, autoincrement=True, primary_key=True) > > created = Column(DateTime, default=datetime.now) > > > class XYZ(DeclarativeBase): > > __tablename__ = 'xyz' > > id = Column(Integer, autoincrement=True, primary_key=True) > > abc = Column(ForeignKey('abc.id', onupdate='CASCADE', > > ondelete='CASCADE')) > > to use ondelete cascade you need to create the onetomany part of the relation, > and give it the passive_deletes='all'.> When a row in ABC table is deleted > (via application), the associated > > row (ForeignKey) in XYZ table is not deleted, instead it has the 'abc' > > column set to NULL. > > > The documentation > > @http://www.sqlalchemy.org/docs/core/schema.html#on-update-and-on-delete > > states the following: > > Note that these clauses are not supported on SQLite, and require > > InnoDB tables when > > used with MySQL. They may also not be supported on other > > databases. > > > I do not setup any special config in MySQL nor in TG2 regarding > > InnoDB. > > perharps this may be set by default?> Question 1: Why does the > ondelete='CASCADE' seem to work for the > > external tg_user_group (M-to-M relation), whereas it does not work for > > the above scenario, in the same application. > > sa also offers cascading implementations through cascade='all,delete-orphan', > that may work even if cascading is not supported by the rdbms. > > > Thanks! -- You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en.

