diff options
author | Anders Elfving <elfving.anders@gmail.com> | 2011-03-13 11:49:56 +0100 |
---|---|---|
committer | Anders Elfving <elfving.anders@gmail.com> | 2011-03-13 11:49:56 +0100 |
commit | 9b64399684ded345e1006a0b5d54f94f5f44f121 (patch) | |
tree | 8159dd20311e551a1af9b14626d56bf29a94d050 /activerecord/lib/active_record/validations | |
parent | deae670e9a8c042ed24a7262b91283f05bcaa3d6 (diff) | |
download | rails-9b64399684ded345e1006a0b5d54f94f5f44f121.tar.gz rails-9b64399684ded345e1006a0b5d54f94f5f44f121.tar.bz2 rails-9b64399684ded345e1006a0b5d54f94f5f44f121.zip |
Adjust unique constraint comment to include info about the RecordNotUnique exception
Diffstat (limited to 'activerecord/lib/active_record/validations')
-rw-r--r-- | activerecord/lib/active_record/validations/uniqueness.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index a96796f9ff..9cd6c26322 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -173,10 +173,17 @@ module ActiveRecord # This technique is also known as optimistic concurrency control: # http://en.wikipedia.org/wiki/Optimistic_concurrency_control # - # Active Record currently provides no way to distinguish unique - # index constraint errors from other types of database errors, so you - # will have to parse the (database-specific) exception message to detect - # such a case. + # The bundled ActiveRecord::ConnectionAdapters distinguish unique index + # constraint errors from other types of database errors by throwing an + # ActiveRecord::RecordNotUnique exception. + # For other adapters you will have to parse the (database-specific) exception + # message to detect such a case. + # The following bundled adapters throw the ActiveRecord::RecordNotUnique exception: + # * ActiveRecord::ConnectionAdapters::MysqlAdapter + # * ActiveRecord::ConnectionAdapters::Mysql2Adapter + # * ActiveRecord::ConnectionAdapters::SQLiteAdapter + # * ActiveRecord::ConnectionAdapters::SQLite3Adapter + # * ActiveRecord::ConnectionAdapters::PostgreSQLAdapter # def validates_uniqueness_of(*attr_names) validates_with UniquenessValidator, _merge_attributes(attr_names) |