summaryrefslogtreecommitdiff
path: root/app/models/snippet.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r--app/models/snippet.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 2a5f07a15c4..e621404f3ae 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -9,6 +9,7 @@ class Snippet < ActiveRecord::Base
include Mentionable
include Spammable
include Editable
+ include Gitlab::SQL::Pattern
extend Gitlab::CurrentSettings
@@ -136,7 +137,7 @@ class Snippet < ActiveRecord::Base
# Returns an ActiveRecord::Relation.
def search(query)
t = arel_table
- pattern = "%#{query}%"
+ pattern = to_pattern(query)
where(t[:title].matches(pattern).or(t[:file_name].matches(pattern)))
end
@@ -149,10 +150,7 @@ class Snippet < ActiveRecord::Base
#
# Returns an ActiveRecord::Relation.
def search_code(query)
- table = Snippet.arel_table
- pattern = "%#{query}%"
-
- where(table[:content].matches(pattern))
+ where(arel_table[:content].matches(to_pattern(query)))
end
end
end