Fix Gitlab::Database.bulk_insert for non-UTF-8 data

This commit is contained in:
Sean McGivern 2017-06-26 17:21:40 +01:00
parent 676c559409
commit d4a3474b9b
2 changed files with 5 additions and 1 deletions

View File

@ -93,7 +93,7 @@ module Gitlab
row.values_at(*keys).map { |value| connection.quote(value) }
end
connection.execute <<-EOF.strip_heredoc
connection.execute <<-EOF
INSERT INTO #{table} (#{columns.join(', ')})
VALUES #{tuples.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')}
EOF

View File

@ -176,6 +176,10 @@ describe Gitlab::Database, lib: true do
described_class.bulk_insert('test', rows)
end
it 'handles non-UTF-8 data' do
expect { described_class.bulk_insert('test', [{ a: "\255" }]) }.not_to raise_error
end
end
describe '.create_connection_pool' do