Commit c141d543 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Make sure this work both on PostgreSQL and MySQL

parent 60df8742
...@@ -209,7 +209,7 @@ module EE ...@@ -209,7 +209,7 @@ module EE
values = { values = {
wildcard: '*', wildcard: '*',
environment_name: environment.name, environment_name: environment.name
} }
quoted_values = quoted_values =
......
...@@ -32,19 +32,19 @@ describe Gitlab::SQL::Glob, lib: true do ...@@ -32,19 +32,19 @@ describe Gitlab::SQL::Glob, lib: true do
end end
def match(string, pattern) def match(string, pattern)
query("SELECT #{quote(string)} LIKE #{pattern} AS match") value = query("SELECT #{quote(string)} LIKE #{pattern}")
.first['match'] .rows.flatten.first
end
def query(sql)
result = ActiveRecord::Base.connection.exec_query(sql)
result.map do |row| case value
row.each_with_object({}) do |(column, value), hash| when 't', 1
hash[column] = true
result.column_types[column].type_cast_from_database(value) else
false
end end
end end
def query(sql)
ActiveRecord::Base.connection.select_all(sql)
end end
def quote(string) def quote(string)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment