mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #43286 from soartec-lab/task/fix-document-for-activerecord-uniqueness-validate
Fixed guide to `case_sensitive` option for Activerecord uniqueness validator [skip ci]
This commit is contained in:
commit
4e35354917
2 changed files with 2 additions and 4 deletions
|
@ -161,7 +161,7 @@ module ActiveRecord
|
||||||
# <tt>WHERE</tt> SQL fragment to limit the uniqueness constraint lookup
|
# <tt>WHERE</tt> SQL fragment to limit the uniqueness constraint lookup
|
||||||
# (e.g. <tt>conditions: -> { where(status: 'active') }</tt>).
|
# (e.g. <tt>conditions: -> { where(status: 'active') }</tt>).
|
||||||
# * <tt>:case_sensitive</tt> - Looks for an exact match. Ignored by
|
# * <tt>:case_sensitive</tt> - Looks for an exact match. Ignored by
|
||||||
# non-text columns (+true+ by default).
|
# non-text columns. The default behavior respects the default database collation.
|
||||||
# * <tt>:allow_nil</tt> - If set to +true+, skips this validation if the
|
# * <tt>:allow_nil</tt> - If set to +true+, skips this validation if the
|
||||||
# attribute is +nil+ (default is +false+).
|
# attribute is +nil+ (default is +false+).
|
||||||
# * <tt>:allow_blank</tt> - If set to +true+, skips this validation if the
|
# * <tt>:allow_blank</tt> - If set to +true+, skips this validation if the
|
||||||
|
|
|
@ -689,9 +689,7 @@ end
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
There is also a `:case_sensitive` option that you can use to define whether the
|
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.
|
||||||
uniqueness constraint will be case sensitive or not. This option defaults to
|
|
||||||
true.
|
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class Person < ApplicationRecord
|
class Person < ApplicationRecord
|
||||||
|
|
Loading…
Reference in a new issue