summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/version.rb2
-rw-r--r--test/unit/version_test.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/app/models/version.rb b/app/models/version.rb
index 74c3309e9..53d1d7758 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -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') }
diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb
index fe4993ca6..40014375a 100644
--- a/test/unit/version_test.rb
+++ b/test/unit/version_test.rb
@@ -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={})