From 5b979ed8ffe5f42747141f632656571f0fd194bf Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 5 Nov 2006 19:20:39 +0000 Subject: Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. Closes #6495. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5434 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/CHANGELOG | 2 ++ activerecord/lib/active_record/validations.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index ce8c1558e2..52068e461e 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Consistently use LOWER() for uniqueness validations (rather than mixing with UPPER()) so the database can always use a functional index on the lowercased column. #6495 [Si] + * SQLite: fix calculations workaround, remove count(distinct) query rewrite, cleanup test connection scripts. [Jeremy Kemper] * SQLite: count(distinct) queries supported in >= 3.2.6. #6544 [Bob Silva] diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 606362eacd..7d77f35a7a 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -533,8 +533,8 @@ module ActiveRecord condition_sql = "#{record.class.table_name}.#{attr_name} #{attribute_condition(value)}" condition_params = [value] else - condition_sql = "UPPER(#{record.class.table_name}.#{attr_name}) #{attribute_condition(value)}" - condition_params = [value.upcase] + condition_sql = "LOWER(#{record.class.table_name}.#{attr_name}) #{attribute_condition(value)}" + condition_params = [value.downcase] end if scope = configuration[:scope] Array(scope).map do |scope_item| -- cgit v1.2.3