On Thursday, January 24, 2013 3:23:00 PM UTC-8, Tim Craft wrote: > > I've just pushed a commit that makes Sequel handle constraint violations > by > > raising different exception classes depending on the type of constraint > > being violated (unique, check, foreign key, not null): > > > https://github.com/jeremyevans/sequel/commit/3b74892e922306539fe29a37aaf895b9e102f402 > > > Awesome, thanks! Just testing it out and experiencing a weird issue > with sqlite3, using a simple varchar column with unique: true. > > With sqlite3 1.3.6 I get Sequel::UniqueConstraintViolation as > expected, but with sqlite3 1.3.7 I get > Sequel::CheckConstraintViolation. Both are wrapping a > SQLite3::ConstraintException, but the message appears to have changed > from "column X is not unique" to just "constraint failed". > > Presumably a regression in sqlite3, will investigate further. >
Weird, I'm not sure why 1.3.7 vs 1.3.6 would make a difference, and I'm pretty sure I was testing on 1.3.7. Unfortunately, parsing exception messages with regexps is pretty fragile, and I'll just have to wait for feedback to update the regexps. If there is another way to determine what type of exception is violated, we should probably use that, but usually that's adapter or even subadapter specific, while the support I added is mostly database specific. At the least, I think the check constraint regexp I used on SQLite is to general. If it only says "constraint failed", I should probably be raising a generic Sequel::ConstraintViolation. That's what I do on jdbc/sqlite since it doesn't have specific constraint exception messages. I'll make that change tomorrow and update the guards in the specs. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
