diff --git a/apptax/taxonomie/commands/migrate_taxref/data/changes_detection/1.2_taxref_changes_detections_cas_actions.sql b/apptax/taxonomie/commands/migrate_taxref/data/changes_detection/1.2_taxref_changes_detections_cas_actions.sql index ec9523b4..4a88113d 100755 --- a/apptax/taxonomie/commands/migrate_taxref/data/changes_detection/1.2_taxref_changes_detections_cas_actions.sql +++ b/apptax/taxonomie/commands/migrate_taxref/data/changes_detection/1.2_taxref_changes_detections_cas_actions.sql @@ -184,22 +184,26 @@ WHERE a.i_cd_ref = c.i_cd_ref -- ---------------------------------------------------------------------- -- Medium & attributs: case "merge", detect conflicts for attributs WITH atts AS ( - SELECT DISTINCT * + SELECT + f_cd_ref, + id_attribut, + valeur_attribut FROM taxonomie.cor_taxon_attribut AS a JOIN tmp_taxref_changes.comp_grap AS c ON a.cd_ref = c.i_cd_ref WHERE valeur_attribut != '{}' AND valeur_attribut != '' AND cas = 'merge' + AND i_cd_ref = ANY(f_array_agg) ), conflict_atts AS ( SELECT f_cd_ref, id_attribut, - count(DISTINCT valeur_attribut) + count(valeur_attribut) FROM atts GROUP BY f_cd_ref, id_attribut - HAVING count(DISTINCT valeur_attribut) > 1 + HAVING count(valeur_attribut) > 1 ), conflict_atts_text AS ( SELECT diff --git a/apptax/taxonomie/commands/migrate_taxref/data/specific_taxref_v15_v16/3.2_alter_taxref_data.sql b/apptax/taxonomie/commands/migrate_taxref/data/specific_taxref_v15_v16/3.2_alter_taxref_data.sql index 800e8d69..3b073ec2 100755 --- a/apptax/taxonomie/commands/migrate_taxref/data/specific_taxref_v15_v16/3.2_alter_taxref_data.sql +++ b/apptax/taxonomie/commands/migrate_taxref/data/specific_taxref_v15_v16/3.2_alter_taxref_data.sql @@ -389,7 +389,8 @@ UPDATE taxonomie.t_medias SET cd_ref = f_cd_ref FROM tmp_taxref_changes.comp_grap WHERE action ILIKE '%Merge attributes%' - AND cd_ref = i_cd_ref ; + AND cd_ref = i_cd_ref + AND i_cd_ref = ANY(f_array_agg) ; ALTER TABLE taxonomie.t_medias ENABLE TRIGGER USER ; @@ -424,7 +425,8 @@ UPDATE taxonomie.cor_taxon_attribut SET cd_ref = f_cd_ref FROM tmp_taxref_changes.comp_grap WHERE action ILIKE '%Merge attributes%' - AND cd_ref = i_cd_ref ; + AND cd_ref = i_cd_ref + AND i_cd_ref = ANY(f_array_agg) ; -- ######################################################################