Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-12-07 05:34:58 +0300
committerStan Hu <stanhu@gmail.com>2017-12-07 05:34:58 +0300
commit29e39e55c3d4b5c6c34c6faec84b0dcd5a3efffa (patch)
treed6b3ca53d05fa47db768c8d0508fe51c81b0f6ac /lib/gitlab/database.rb
parentba44a57f101a87ebb9155485d5bde1287f7892cf (diff)
parent24c348f0d1270fe27268aa23e034473651b0cdf9 (diff)
Merge branch 'mk-add-old-attachments-to-uploads-table' into 'master'
Add old files to uploads table See merge request gitlab-org/gitlab-ce!15270
Diffstat (limited to 'lib/gitlab/database.rb')
-rw-r--r--lib/gitlab/database.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index 96922e1a62f..e51794fef99 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -120,15 +120,21 @@ module Gitlab
# values.
# return_ids - When set to true the return value will be an Array of IDs of
# the inserted rows, this only works on PostgreSQL.
- def self.bulk_insert(table, rows, return_ids: false)
+ # disable_quote - A key or an Array of keys to exclude from quoting (You
+ # become responsible for protection from SQL injection for
+ # these keys!)
+ def self.bulk_insert(table, rows, return_ids: false, disable_quote: [])
return if rows.empty?
keys = rows.first.keys
columns = keys.map { |key| connection.quote_column_name(key) }
return_ids = false if mysql?
+ disable_quote = Array(disable_quote).to_set
tuples = rows.map do |row|
- row.values_at(*keys).map { |value| connection.quote(value) }
+ keys.map do |k|
+ disable_quote.include?(k) ? row[k] : connection.quote(row[k])
+ end
end
sql = <<-EOF