Skip to content

Commit

Permalink
Revert case sensitivity for email uniqueness (#930)
Browse files Browse the repository at this point in the history
In #889, `case_sensitive` setting of the `uniqueness` validator was set
to `false` to prevent deprecation warnings from Rails.

However, the setting should have been set to `true` to preserve
backwards-compatibility.

The deprecation warning said:

> To **continue** case sensitive comparison
> on the :email attribute in User model, pass case_sensitive: true
> option explicitly to the uniqueness validator.

Setting it to `false`, made ActiveRecord generate User queries on
`LOWER(email)` instead of on `email`. The apps that didn't have an index
on `LOWER(email)` would have faced performance issues.

This was mentioned in an old commit that originally made the switch from
`false` to the implicit `true`:
56f0f04
  • Loading branch information
sidonath committed Feb 26, 2021
1 parent 6e66881 commit b50defc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/clearance/user.rb
Expand Up @@ -152,7 +152,7 @@ module Validations
validates :email,
email: { strict_mode: true },
presence: true,
uniqueness: { allow_blank: true, case_sensitive: false },
uniqueness: { allow_blank: true, case_sensitive: true },
unless: :email_optional?

validates :password, presence: true, unless: :skip_password_validation?
Expand Down

0 comments on commit b50defc

Please sign in to comment.