On Sunday, January 20, 2013 9:10:43 AM UTC-8, Tim Craft wrote:

> Inserting/updating records with non-unique values for columns with a 
> unique constraint raises a Sequel::DatabaseError exception. It's difficult 
> to separate/distinguish this error because of the common exception class 
> and because different database adapters use different error messages. 
> Resulting in something like this (for sqlite/postgres): 
> https://gist.github.com/4579910
>
> ActiveRecord has a RecordNotUnique exception class to handle this, does 
> Sequel have anything similar?
>

Sequel does not currently have something similar.  Database drivers 
generally do not provide specific methods that can be called to determine 
this, so it must be done by parsing exception messages in most cases. 
 Sequel currently does that for disconnect detection on most adapters, and 
it is difficult to get correct, as there are generally different messages 
for different types of disconnects.

There have been few requests for such support in the previous 5 years (I 
can find only 1, back in 2009), so I'm not sure how many people actually 
need this.  Most people who would need such a thing are probably using 
models with validates_unique, and probably don't have a problem with 
raising a regular exception if the race is lost.  That being said, it seems 
like a useful thing to me, so I'll look into implementing it.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/eZKlVOlsQt0J.
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/sequel-talk?hl=en.

Reply via email to