Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 13 and Version 14 of SimpleDelete


Ignore:
Timestamp:
03/23/06 10:19:44 (13 years ago)
Author:
baruch
Comment:

OP says: The way to do cascade deletes is documented in the core, no need for the extra discussion anymore

Legend:

Unmodified
Added
Removed
Modified
  • SimpleDelete

    v13 v14  
    3939 
    4040''- Jorge Godoy'' 
    41  
    42 ------ 
    43  
    44 How do I go about deleting a bunch of related items? 
    45  
    46 I have a User and he has Items, I want to delete the User with his Items. Right now I go around and loop on the user.items and .destroySelf them, but that's inefficient SQL. I could just do "DELETE FROM item WHERE item.userID = x". Is there anyway to achieve it with SQLObject? 
    47  
    48 ------ 
    49  
    50 Using the SQL cascade feature is the way to go.  This way, you delete the user and everything that allows cascading will also be deleted.  You'll still get an error for tables that have records referencing said user and that doesn't allow cascading (then, when the transaction is rolled back, everything will still be there...).  
    51  
    52 By the way, it is better to ask questions on the mailing list since it is hard to find and answer questions here. 
    53  
    54 ''- Jorge Godoy'' 
    55  
    56 ------ 
    57  
    58 Thanks for the tip. It appears that you can add the cascade option to an attribute though I still haven't worked out what's the option I need for it. It takes one of three options: True, False and 'null' (yes, that's two booleans and a string). It also appears to only be effective for PostgreSQL, and there is absolutely no documentation about it.