Module: Gitlab::SQL::Glob

Extended by:
Glob
Included in:
Glob
Defined in:
lib/gitlab/sql/glob.rb

Instance Method Summary collapse

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)
  "    REPLACE(REPLACE(REPLACE(\#{pattern},\n                            \#{q('%')}, \#{q('\\\\%')}),\n                    \#{q('_')}, \#{q('\\\\_')}),\n            \#{q('*')}, \#{q('%')})\n  SQL\nend\n"