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:
authorMichael Kozono <mkozono@gmail.com>2017-11-24 21:04:44 +0300
committerMichael Kozono <mkozono@gmail.com>2017-12-02 02:26:42 +0300
commit3694fe0f3d43619174878805ba09f0943e1dbaad (patch)
tree7a98c4ed0a69a50263b4a3b0061b49f6b4b36a18 /lib/gitlab/database.rb
parent6e36452e96139658ff8eae88209710438dd14eba (diff)
Don’t quote `NOW()` for created_at column
To fix for MySQL.
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 cd7b4c043da..16308b308b2 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -116,15 +116,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) }
+ row.keys.map do |k|
+ disable_quote.include?(k) ? row[k] : connection.quote(row[k])
+ end
end
sql = <<-EOF