Skip to content

Commit 4e35354

Browse files
Merge pull request rails#43286 from soartec-lab/task/fix-document-for-activerecord-uniqueness-validate
Fixed guide to `case_sensitive` option for Activerecord uniqueness validator [skip ci]
2 parents e44ce53 + 613b9ae commit 4e35354

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

activerecord/lib/active_record/validations/uniqueness.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ module ClassMethods
161161
# <tt>WHERE</tt> SQL fragment to limit the uniqueness constraint lookup
162162
# (e.g. <tt>conditions: -> { where(status: 'active') }</tt>).
163163
# * <tt>:case_sensitive</tt> - Looks for an exact match. Ignored by
164-
# non-text columns (+true+ by default).
164+
# non-text columns. The default behavior respects the default database collation.
165165
# * <tt>:allow_nil</tt> - If set to +true+, skips this validation if the
166166
# attribute is +nil+ (default is +false+).
167167
# * <tt>:allow_blank</tt> - If set to +true+, skips this validation if the

guides/source/active_record_validations.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,7 @@ end
689689

690690
Should you wish to create a database constraint to prevent possible violations of a uniqueness validation using the `:scope` option, you must create a unique index on both columns in your database. See [the MySQL manual](https://dev.mysql.com/doc/refman/en/multiple-column-indexes.html) for more details about multiple column indexes or [the PostgreSQL manual](https://www.postgresql.org/docs/current/static/ddl-constraints.html) for examples of unique constraints that refer to a group of columns.
691691

692-
There is also a `:case_sensitive` option that you can use to define whether the
693-
uniqueness constraint will be case sensitive or not. This option defaults to
694-
true.
692+
There is also a `:case_sensitive` option that you can use to define whether the uniqueness constraint will be case sensitive, case insensitive, or respects default database collation. This option defaults to respects default database collation.
695693

696694
```ruby
697695
class Person < ApplicationRecord

0 commit comments

Comments
 (0)