Strip newlines from obfuscated SQL

Newlines aren't really needed and they may mess with InfluxDB's line
protocol.
This commit is contained in:
Yorick Peterse 2015-12-29 13:40:08 +01:00
parent 58bc4b72d5
commit 03478e6d5b
2 changed files with 7 additions and 1 deletions

View File

@ -40,7 +40,7 @@ module Gitlab
sql = sql.delete('"')
end
sql
sql.gsub("\n", ' ')
end
end
end

View File

@ -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')