Permalink
Browse files

Merge pull request #13291 from strzibny/new_unique_constraint

Translate new unique constraint error message for sqlite >= 3.8.2
  • Loading branch information...
2 parents 5c5d508 + 89622b9 commit 02a81b84ebb7fc16dc2ae4609277e8251f232f95 @senny senny committed Dec 12, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -586,7 +586,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 02a81b8

Please sign in to comment.