fix(dossier): prevent crash when updating champs in rebase

This commit is contained in:
Paul Chavard 2023-02-07 10:52:43 +01:00
parent ea51e7d3f5
commit 1693e46acb

View file

@ -77,9 +77,11 @@ module DossierRebaseConcern
# due to repetition tdc clone on update or erase # due to repetition tdc clone on update or erase
# we must reassign tdc to the latest version # we must reassign tdc to the latest version
champs_by_stable_id champs_by_stable_id.each do |stable_id, champs|
.filter_map { |stable_id, champs| [target_coordinates_by_stable_id[stable_id].type_de_champ_id, champs] if champs.present? } if target_coordinates_by_stable_id[stable_id].present? && champs.present?
.each { |type_de_champ_id, champs| champs.update_all(type_de_champ_id:) } champs.update_all(type_de_champ_id: target_coordinates_by_stable_id[stable_id].type_de_champ_id)
end
end
# update dossier revision # update dossier revision
update_column(:revision_id, target_revision.id) update_column(:revision_id, target_revision.id)