diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-29 15:40:08 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-29 15:40:08 +0300 |
commit | 03478e6d5b98a723fbb349dac2c8495f75909a08 (patch) | |
tree | 32efd1ea84514b93f1597baacba7682711f044c0 | |
parent | 58bc4b72d519d971be7c3eb80f174d9e22f2a1b2 (diff) |
Strip newlines from obfuscated SQL
Newlines aren't really needed and they may mess with InfluxDB's line
protocol.
-rw-r--r-- | lib/gitlab/metrics/obfuscated_sql.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/metrics/obfuscated_sql_spec.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/gitlab/metrics/obfuscated_sql.rb b/lib/gitlab/metrics/obfuscated_sql.rb index 481aca56efb..2e932fb3049 100644 --- a/lib/gitlab/metrics/obfuscated_sql.rb +++ b/lib/gitlab/metrics/obfuscated_sql.rb @@ -40,7 +40,7 @@ module Gitlab sql = sql.delete('"') end - sql + sql.gsub("\n", ' ') end end end diff --git a/spec/lib/gitlab/metrics/obfuscated_sql_spec.rb b/spec/lib/gitlab/metrics/obfuscated_sql_spec.rb index 0f01ee588c9..2b681c9fe34 100644 --- a/spec/lib/gitlab/metrics/obfuscated_sql_spec.rb +++ b/spec/lib/gitlab/metrics/obfuscated_sql_spec.rb @@ -2,6 +2,12 @@ require 'spec_helper' describe Gitlab::Metrics::ObfuscatedSQL do describe '#to_s' do + it 'replaces newlines with a space' do + sql = described_class.new("SELECT x\nFROM y") + + expect(sql.to_s).to eq('SELECT x FROM y') + end + describe 'using single values' do it 'replaces a single integer' do sql = described_class.new('SELECT x FROM y WHERE a = 10') |