Permalink
Browse files

Translate new unique constraint for sqlite >= 3.8.2

  • Loading branch information...
1 parent fee49a1 commit 89622b92afaa5bde4cd2a3dea70c49e24e15211f Josef Stribny committed Dec 12, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -595,7 +595,11 @@ def sqlite_version
def translate_exception(exception, message)
case exception.message
- when /column(s)? .* (is|are) not unique/
+ # SQLite 3.8.2 returns a newly formatted error message:
+ # UNIQUE constraint failed: *table_name*.*column_name*
+ # Older versions of SQLite return:
+ # column *column_name* is not unique
+ when /column(s)? .* (is|are) not unique/, /UNIQUE constraint failed: .*/
RecordNotUnique.new(message, exception)
else
super

0 comments on commit 89622b9

Please sign in to comment.