On 11/9/07, ara.t.howard <[EMAIL PROTECTED]> wrote: > given that this happens to be the case > > http://drawohara.tumblr.com/post/18926188 > > it seems that *any* validation should alter the behavior of > Base#create to force the isolation level - otherwise validations end > up being nothing be a stack of race conditions. sorry if i'm late to > the party but this came as a real surprise to me. at the very least > it seems the docs should have a big fat warning about this or the > code itself should warn when using validations and the client code is > not under a strictly serializable transaction.
Hey Ara, a one-two punch of validates_uniqueness_of plus a unique index on those fields gives you nice error messages in the common case and a rare database exception otherwise. This should definitely be in the docs. Now, if we could parse the db constraint violation error message to deduce the type of constraint that failed and the affected fields, then we could turn the dumb exception (StatementInvalid) into a smart one (UniquenessConstraintViolation), rescue it in Base#save_with_validations, and add the message to record.errors. Unfortunately I tried it with postgres a while back and the db errors left too much up to the imagination to get much further than a neat demo. Best, jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---