diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-11-24 11:45:19 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-11-24 17:28:50 +0100 |
commit | aedd2cfa5b82c01f82ec26b64880fce2a07fe942 (patch) | |
tree | e8c2094d81b86a471fdbb9de4f4a279ec0a0ef75 /app/models/snippet.rb | |
parent | b355ebc4c9b38320366d7640ecf51da23fbb7ea1 (diff) | |
download | gitlab-ce-aedd2cfa5b82c01f82ec26b64880fce2a07fe942.tar.gz |
Use Gitlab::SQL::Pattern where appropriate
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r-- | app/models/snippet.rb | 8 |
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 |