[sqlalchemy] Re: child counting + delete

2008-10-27 Thread Michael Bayer
On Oct 27, 2008, at 4:23 PM, GustaV wrote: Ok it looks good... I assume it also means I can't rely on ON DELETE CASCADE anymore, and I then must use passive_deletes=False. At least on those relations. I dont see why that's the case here. It depends on the specific scenario, but in

[sqlalchemy] Re: child counting + delete

2008-10-27 Thread GustaV
Ok! My mistake! I completely made it now. Thanks again. On 27 oct, 22:08, Michael Bayer [EMAIL PROTECTED] wrote: Just as a note, if you're using ON DELETE CASCADE with passive_deletes=True, SQLA will still explicitly delete whatever objects might already be loaded into collections, so that

[sqlalchemy] Re: child counting + delete

2008-10-27 Thread Michael Bayer
Just as a note, if you're using ON DELETE CASCADE with passive_deletes=True, SQLA will still explicitly delete whatever objects might already be loaded into collections, so that the Session stays in sync with what's currently in it. the CASCADE then occurs after this when SQLA deletes

[sqlalchemy] Re: child counting + delete

2008-10-22 Thread GustaV
Ok... I'm not sure to understand the way you do it... Does it mean I should check the add and delete of regions in the transaction in after_flush() and issue sql directly (not using the ORM) to update the count in Country? On 22 oct, 20:46, Michael Bayer [EMAIL PROTECTED] wrote: On Oct 22,

[sqlalchemy] Re: child counting + delete

2008-10-22 Thread Michael Bayer
I do this kind of thing...theres lots of variants on how to do this but the idea of __after_flush__ is that everything, including collections, have been committed (but the new, dirty and deleted lists have not been reset yet): class OnFlushExt(orm.SessionExtension): def