[Dbix-class] Optimistic locking

Dan Horne dan.horne at redbone.co.nz
Fri Aug 4 19:07:40 CEST 2006


Hi

I'd like to implement a form of optimistic locking in one of my apps. Rather
than handle this manually in the app itself, I'm hoping to reduce the coding
overhead by incorporating the logic in a DBIC component. The basic steps
are:

1. Generate a pseudocolumn that contains a hash of the current row (or
allrows if $rs->all). 
2. At some point in the future, a user will try to save the record via a
webform. The overridden update method will query the original row and
recompute the hash. If the two hashes don't match, an exception will be
thrown.

So, my question is: Is there any way to create such a pseudocolumn that can
be populated as a result of the values of the other columns?

Regards

Dan




More information about the Dbix-class mailing list