]> source.dussan.org Git - redmine.git/commitdiff
Filter for version name should be case-insensitive (#27122).
authorGo MAEDA <maeda@farend.jp>
Sat, 28 Apr 2018 23:31:49 +0000 (23:31 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 28 Apr 2018 23:31:49 +0000 (23:31 +0000)
Patch by Holger Just and Mizuki ISHIKAWA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17316 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/version.rb
test/unit/version_test.rb

index 74c3309e9a5772ef9bfc8dbaf04272f65bc9fc0b..53d1d77587dd7c391b2fdb64d4889014564518f5 100644 (file)
@@ -134,7 +134,7 @@ class Version < ActiveRecord::Base
   scope :like, lambda {|arg|
     if arg.present?
       pattern = "%#{arg.to_s.strip}%"
-      where("LOWER(#{Version.table_name}.name) LIKE :p", :p => pattern)
+      where([Redmine::Database.like("#{Version.table_name}.name", '?'), pattern])
     end
   }
   scope :open, lambda { where(:status => 'open') }
index fe4993ca6af0c1dba920929ae95c334773264958..40014375ac55d0f91ec2d34e07fb1884e78ffd6c 100644 (file)
@@ -277,6 +277,14 @@ class VersionTest < ActiveSupport::TestCase
     assert_equal false, version.deletable?
   end
 
+  def test_like_scope
+    version = Version.create!(:project => Project.find(1), :name => 'Version for like scope test')
+
+    assert_includes Version.like('VERSION FOR LIKE SCOPE TEST'), version
+    assert_includes Version.like('version for like scope test'), version
+    assert_includes Version.like('like scope'), version
+  end
+
   private
 
   def add_issue(version, attributes={})