diff options
author | Josef Stribny <jstribny@redhat.com> | 2013-12-12 11:27:20 +0100 |
---|---|---|
committer | Josef Stribny <jstribny@redhat.com> | 2013-12-12 16:02:14 +0100 |
commit | 89622b92afaa5bde4cd2a3dea70c49e24e15211f (patch) | |
tree | 06653b46ce44d46e9753d0c34920e6bf56939a4c /activerecord | |
parent | fee49a10492efc99409c03f7096d5bd3377b0bbc (diff) | |
download | rails-89622b92afaa5bde4cd2a3dea70c49e24e15211f.tar.gz rails-89622b92afaa5bde4cd2a3dea70c49e24e15211f.tar.bz2 rails-89622b92afaa5bde4cd2a3dea70c49e24e15211f.zip |
Translate new unique constraint for sqlite >= 3.8.2
Diffstat (limited to 'activerecord')
-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 e5ad08b6b0..19fa8502d3 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -595,7 +595,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 |