Project

General

Profile

« Previous | Next » 

Revision 5554

schemas/vegbien.sql: taxonconcept: taxonconcept_update_ancestors() trigger: Fixed bug where matched_concept_id needed to be changed to NULL when equal to taxonconcept_id, to avoid including the node itself with its parent's ancestors (which would violate the taxonconcept_ancestor pkey)

View differences:

schemas/tree_cross-links.sql
8 8
$BODY$
9 9
DECLARE
10 10
    -- Use matched_concept_id's ancestors instead if available
11
    parent_id_ taxonconcept.taxonconcept_id%TYPE :=
12
        COALESCE(new.matched_concept_id, new.parent_id);
11
    parent_id_ taxonconcept.taxonconcept_id%TYPE := COALESCE(
12
        NULLIF(new.matched_concept_id, new.taxonconcept_id), new.parent_id);
13 13
BEGIN
14 14
    IF parent_id_ IS DISTINCT FROM old_parent_id THEN
15 15
        DECLARE
......
77 77
  RETURNS trigger AS
78 78
$BODY$
79 79
BEGIN
80
    PERFORM taxonconcept_update_ancestors(new,
81
        COALESCE(old.matched_concept_id, old.parent_id));
80
    PERFORM taxonconcept_update_ancestors(new, COALESCE(
81
        NULLIF(old.matched_concept_id, old.taxonconcept_id), old.parent_id));
82 82
    
83 83
    RETURN new;
84 84
END;
schemas/vegbien.sql
675 675
    AS $$
676 676
DECLARE
677 677
    -- Use matched_concept_id's ancestors instead if available
678
    parent_id_ taxonconcept.taxonconcept_id%TYPE :=
679
        COALESCE(new.matched_concept_id, new.parent_id);
678
    parent_id_ taxonconcept.taxonconcept_id%TYPE := COALESCE(
679
        NULLIF(new.matched_concept_id, new.taxonconcept_id), new.parent_id);
680 680
BEGIN
681 681
    IF parent_id_ IS DISTINCT FROM old_parent_id THEN
682 682
        DECLARE
......
750 750
    LANGUAGE plpgsql
751 751
    AS $$
752 752
BEGIN
753
    PERFORM taxonconcept_update_ancestors(new,
754
        COALESCE(old.matched_concept_id, old.parent_id));
753
    PERFORM taxonconcept_update_ancestors(new, COALESCE(
754
        NULLIF(old.matched_concept_id, old.taxonconcept_id), old.parent_id));
755 755
    
756 756
    RETURN new;
757 757
END;

Also available in: Unified diff