diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-05 19:20:39 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-05 19:20:39 +0000 |
commit | 5b979ed8ffe5f42747141f632656571f0fd194bf (patch) | |
tree | f92c02993f38d091dae7841a80d80e9be64d3a1a /activerecord | |
parent | 7b453d28449527aeac18395c471e3010a15fbb31 (diff) | |
download | rails-5b979ed8ffe5f42747141f632656571f0fd194bf.tar.gz rails-5b979ed8ffe5f42747141f632656571f0fd194bf.tar.bz2 rails-5b979ed8ffe5f42747141f632656571f0fd194bf.zip |
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
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | 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| |