Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 02a81b84ebb7fc16dc2ae4609277e8251f232f95 2 parents 5c5d508 + 89622b9
@senny senny authored
View
6 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
Please sign in to comment.
Something went wrong with that request. Please try again.