Skip to content

Commit

Permalink
fix(migrate_taxref): ignore false merge conflicts
Browse files Browse the repository at this point in the history
Fix #527.
  • Loading branch information
jpm-cbna committed Aug 9, 2024
1 parent 14532af commit 7304d09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;

Expand Down Expand Up @@ -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) ;


-- ######################################################################
Expand Down

0 comments on commit 7304d09

Please sign in to comment.