This project is archived and is in readonly mode.

#4293 ✓resolved
Aaron Patterson

validates uniqueness of should take advantage of the database

Reported by Aaron Patterson | March 29th, 2010 @ 06:13 AM

Currently, case-insensitive validations use ruby to lower case a string on one side, and the database to lower case on the other. That results in a question that looks like this:

"SELECT     \"topics\".\"id\" FROM       \"topics\" WHERE     (LOWER(\"topics\".\"title\") = E'я тоже УНИКАЛЬНЫЙ!') LIMIT 1"

This is fine, except that sometimes Ruby does not know how to lower case the same way the database does. In fact, with 1.9.2, the "test_validate_case_insensitive_uniqueness" test fails because ruby 1.9 does not downcase the string the same way ruby 1.8 does.

This patch switches the validation to use LOWER() on both sides of the comparison, and avoid what Ruby thinks.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Tags

Referenced by

Pages