diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-12-12 07:30:29 -0800 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-12-12 07:30:29 -0800 |
commit | 02a81b84ebb7fc16dc2ae4609277e8251f232f95 (patch) | |
tree | d5d7b732d4c429ef42eb8e39965ab11b2547d02f | |
parent | 5c5d5080b7ea008f0b4a5bf2e65bb22d24094cea (diff) | |
parent | 89622b92afaa5bde4cd2a3dea70c49e24e15211f (diff) | |
download | rails-02a81b84ebb7fc16dc2ae4609277e8251f232f95.tar.gz rails-02a81b84ebb7fc16dc2ae4609277e8251f232f95.tar.bz2 rails-02a81b84ebb7fc16dc2ae4609277e8251f232f95.zip |
Merge pull request #13291 from strzibny/new_unique_constraint
Translate new unique constraint error message for sqlite >= 3.8.2
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 2cf1015f2c..a02eda5603 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -586,7 +586,11 @@ module ActiveRecord 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 |