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
values = {
wildcard: '*',
environment_name: environment.name,
environment_name: environment.name
}
quoted_values =
......
......@@ -32,19 +32,19 @@ describe Gitlab::SQL::Glob, lib: true do
end
def match(string, pattern)
query("SELECT #{quote(string)} LIKE #{pattern} AS match")
.first['match']
value = query("SELECT #{quote(string)} LIKE #{pattern}")
.rows.flatten.first
case value
when 't', 1
true
else
false
end
end
def query(sql)
result = ActiveRecord::Base.connection.exec_query(sql)
result.map do |row|
row.each_with_object({}) do |(column, value), hash|
hash[column] =
result.column_types[column].type_cast_from_database(value)
end
end
ActiveRecord::Base.connection.select_all(sql)
end
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