Skip to content
Browse files

Adjust unique constraint comment to include info about the RecordNotU…

…nique exception
  • Loading branch information...
1 parent deae670 commit 9b64399684ded345e1006a0b5d54f94f5f44f121 @fevrisn fevrisn committed
Showing with 11 additions and 4 deletions.
  1. +11 −4 activerecord/lib/active_record/validations/uniqueness.rb
View
15 activerecord/lib/active_record/validations/uniqueness.rb
@@ -173,10 +173,17 @@ module ClassMethods
# 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)

0 comments on commit 9b64399

Please sign in to comment.
Something went wrong with that request. Please try again.