Don’t quote `NOW()` for created_at column
To fix for MySQL.
This commit is contained in:
parent
6e36452e96
commit
3694fe0f3d
|
@ -204,7 +204,7 @@ module Gitlab
|
|||
file.to_h.merge(created_at: 'NOW()')
|
||||
end
|
||||
|
||||
Gitlab::Database.bulk_insert('uploads', rows)
|
||||
Gitlab::Database.bulk_insert('uploads', rows, disable_quote: :created_at)
|
||||
end
|
||||
|
||||
def drop_temp_table_if_finished
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue