Commit d4a3474b authored by Sean McGivern's avatar Sean McGivern

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

parent 676c5594
...@@ -93,7 +93,7 @@ module Gitlab ...@@ -93,7 +93,7 @@ module Gitlab
row.values_at(*keys).map { |value| connection.quote(value) } row.values_at(*keys).map { |value| connection.quote(value) }
end end
connection.execute <<-EOF.strip_heredoc connection.execute <<-EOF
INSERT INTO #{table} (#{columns.join(', ')}) INSERT INTO #{table} (#{columns.join(', ')})
VALUES #{tuples.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')} VALUES #{tuples.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')}
EOF EOF
......
...@@ -176,6 +176,10 @@ describe Gitlab::Database, lib: true do ...@@ -176,6 +176,10 @@ describe Gitlab::Database, lib: true do
described_class.bulk_insert('test', rows) described_class.bulk_insert('test', rows)
end end
it 'handles non-UTF-8 data' do
expect { described_class.bulk_insert('test', [{ a: "\255" }]) }.not_to raise_error
end
end end
describe '.create_connection_pool' do describe '.create_connection_pool' do
......
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