summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2015-12-14 12:31:56 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2015-12-17 17:25:48 +0100
commitf932b781a79d9b829001c39bc214372b7efd8610 (patch)
treeb3bcd0307c6a1a0048c379ae7242fd610889d754 /lib
parent09a311568abee739fae0c2577a9cf6aa01516977 (diff)
downloadgitlab-ce-f932b781a79d9b829001c39bc214372b7efd8610.tar.gz
Replace double quotes when obfuscating SQL
InfluxDB escapes double quotes upon output which makes it a pain to deal with. This ensures that if we're using PostgreSQL we don't store any queries containing double quotes in InfluxDB, solving the escaping problem.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/metrics/obfuscated_sql.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/metrics/obfuscated_sql.rb b/lib/gitlab/metrics/obfuscated_sql.rb
index 45f2e2bc62a..7b15670aa6b 100644
--- a/lib/gitlab/metrics/obfuscated_sql.rb
+++ b/lib/gitlab/metrics/obfuscated_sql.rb
@@ -30,9 +30,17 @@ module Gitlab
regex = Regexp.union(regex, MYSQL_REPLACEMENTS)
end
- @sql.gsub(regex, '?').gsub(CONSECUTIVE) do |match|
+ sql = @sql.gsub(regex, '?').gsub(CONSECUTIVE) do |match|
"#{match.count(',') + 1} values"
end
+
+ # InfluxDB escapes double quotes upon output, so lets get rid of them
+ # whenever we can.
+ if Gitlab::Database.postgresql?
+ sql = sql.gsub('"', '')
+ end
+
+ sql
end
end
end