Commit 28c1cf25 authored by Stan Hu's avatar Stan Hu

Merge branch 'bulk-update-params-deep-dup' into 'master'

Use deep_dup in bulk update service

See merge request gitlab-org/gitlab!69138
parents 319c6903 fffa08d5
...@@ -60,7 +60,7 @@ module Issuable ...@@ -60,7 +60,7 @@ module Issuable
update_class.new( update_class.new(
**update_class.constructor_container_arg(issuable.issuing_parent), **update_class.constructor_container_arg(issuable.issuing_parent),
current_user: current_user, current_user: current_user,
params: params.dup params: dup_params
).execute(issuable) ).execute(issuable)
end end
...@@ -82,6 +82,19 @@ module Issuable ...@@ -82,6 +82,19 @@ module Issuable
.includes_for_bulk_update .includes_for_bulk_update
end end
# Duplicates params and its top-level values
# We cannot use deep_dup because ActiveRecord objects will result
# to new records with no id assigned
def dup_params
dup = HashWithIndifferentAccess.new
params.each do |key, value|
dup[key] = value.is_a?(ActiveRecord::Base) ? value : value.dup
end
dup
end
def response_success(message: nil, payload: nil) def response_success(message: nil, payload: nil)
ServiceResponse.success(message: message, payload: payload) ServiceResponse.success(message: message, payload: payload)
end end
......
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