Login Skip Navigation LinksWilsonORMapper > Forums Search
Demo Version Demo Version
Download and try for yourself a fully working demo version, including sample apps and documentation.  The only limitation is that the demo version only works inside the debugger.

PayPal Subscribe
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
PayPal

User Login User Login
Log In
 
 
Reset Password

Wilson ORMapper Forums Wilson ORMapper Forums : Advanced Topics : Logical delete support

Date Post
5/11/2007 9:14:58 AM

Hi,

I'm looking for feedback, and some guidance from those more familiar with WORM then myself, on the best way to do logical deletes with WORM.

For example, I want to set an IsDeleted field to true instead of calling DELETE FROM on the record. Obviously all the SELECT queries on that table need to be modified to include a IsDeleted = 0 where clause.

I asked this question a couple of months ago, but didn't get much of a reply. I've had more of a chance to look through the source code of WORM, and I've had some ideas.

I could write my own adapter, but that looks (a) not re-usable, (b) the wrong place to do it, and (c) prone to mistakes.

I can just intercept the SQL on the way to the DB, and modifiy it as required, but that's a bit nasty, too.

Paul, do you have any suggestions as to how you would approach this? This is a feature I'd be happy to work on, and contribute patches for, so I'd like to fit in with your overall plans for the direction of WORM if possible.

Cheers
Matt

5/11/2007 4:08:10 PM

Hi Matt:

You can create a view that returns only "non-deleted" records and map to it instead of the underlying table.  Then there are two ways to handle your logical "deletes":  (1) always call a "delete" method on your object that hides the reality that its a logical delete, or (2) make a trigger that intercepts deletes and turns them into logical deletes.  Which is "better"?  I don't think there is a single right answer to that.  In some cases it may be better to make the app responsible, while in other cases you must guarantee what happens no matter what in which case the database is the only place to do that.

Thanks, Paul Wilson