Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

validates uniqueness of should take advantage of the database

#4293

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.

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low