On Thu, Feb 14, 2008 at 11:04 AM, Gaetan de Menten <[EMAIL PROTECTED]> wrote: > > On Wed, Feb 13, 2008 at 5:44 PM, Jonathan LaCour > <[EMAIL PROTECTED]> wrote: > > > > Greetings list, > > > > A user recently emailed me about concurrent modifications and the > > versioning extension off-list. My original intention was to allow > > the user to somewhat decide how to handle concurrent modifications > > on their own. The default behavior is pretty undesirable, in that > > you could end up with two version rows with the same version number > > in the case of concurrent writes. > > > > SQLAlchemy has a `version_id_col` argument that can be specified > > to the mapper constructor that will use a 0-based integer version > > column to watch for concurrent modification errors. I have made a > > patch to the versioning extension which makes it possible to have > > this capability turned on for your versioned entities, so that > > ConcurrentModificationErrors will be raised in the case of these > > concurrent writes. > > > > I am attaching a patch to this email, and I'd like to get feedback > > on how I have implemented it. This was a quick job that I did > > late last night when fighting off insomnia, so I am not entirely > > confident in it, and I'd like to hear what people have to say about > > it. > > > > The patch essentially adds an `enforce` keyword argument to the > > `acts_as_versioned` statement. If you pass `True` the extension > > will enable this new behavior. > > > > If I get enough positive feedback, I'll commit it to the trunk. Its > > something that should really be there, I am just not confident that > > I have done it "right" yet :) > > Looks good (though I didn't test it). I think we should even turn it > on by default (because the only reason to not have it IMO is not to > add an extra column to your tables, but in this case, you already have > the extra column). The only minor complaint I have is about the > version which starts at 0 or 1 depending on whether you use "enforce". > Could be confusing...
And, one more thing that just occured to me: the argument name might not be best, as you don't know what it enforces. Something like "check_concurrent" or similar might be more appropriate IMO. -- Gaƫtan de Menten http://openhex.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SQLElixir" 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/sqlelixir?hl=en -~----------~----~----~----~------~----~------~--~---
