Merge pull request #8594 from tchak/fix-rebase-destroy-champ

fix(dossier): prevent crash when updating champs in rebase
This commit is contained in:
Paul Chavard 2023-02-08 15:07:42 +01:00 committed by GitHub
commit 384e861f8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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)