Module: Gitlab::SQL::Glob
Instance Method Summary collapse
- #q(string) ⇒ Object
-
#to_like(pattern) ⇒ Object
Convert a simple glob pattern with wildcard (*) to SQL LIKE pattern with SQL expression.
Instance Method Details
#q(string) ⇒ Object
19 20 21 |
# File 'lib/gitlab/sql/glob.rb', line 19 def q(string) ApplicationRecord.connection.quote(string) end |
#to_like(pattern) ⇒ Object
Convert a simple glob pattern with wildcard (*) to SQL LIKE pattern with SQL expression
10 11 12 13 14 15 16 17 |
# File 'lib/gitlab/sql/glob.rb', line 10 def to_like(pattern) <<~SQL REPLACE(REPLACE(REPLACE(#{pattern}, #{q('%')}, #{q('\\%')}), #{q('_')}, #{q('\\_')}), #{q('*')}, #{q('%')}) SQL end |