diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-01-20 18:22:17 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-01-20 18:22:17 +0100 |
| commit | 0789440e67577a08b22525760f689f38c43eb105 (patch) | |
| tree | 71a409727bb569887f9a055dcef5cfd6de1c6f8a /archaeological_finds/models_treatments.py | |
| parent | 23311a252d4922d60a3ae816db987935a683755f (diff) | |
| download | Ishtar-0789440e67577a08b22525760f689f38c43eb105.tar.bz2 Ishtar-0789440e67577a08b22525760f689f38c43eb105.zip | |
Fix treatment view (refs #3426)
Diffstat (limited to 'archaeological_finds/models_treatments.py')
| -rw-r--r-- | archaeological_finds/models_treatments.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index dacfbfdfc..d8d51e28c 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -310,9 +310,10 @@ class FindUpstreamTreatments(AbsFindTreatments): WITH RECURSIVE rel_tree AS ( SELECT id AS find_id, upstream_treatment_id, downstream_treatment_id, 1 AS level, - array[upstream_treatment_id] AS path_info + ARRAY[]::integer[] AS path_info FROM archaeological_finds_find - WHERE upstream_treatment_id is null + WHERE upstream_treatment_id is NULL AND + downstream_treatment_id is NOT NULL UNION ALL SELECT c.id AS find_id, c.upstream_treatment_id, c.downstream_treatment_id, @@ -320,8 +321,10 @@ class FindUpstreamTreatments(AbsFindTreatments): FROM archaeological_finds_find c JOIN rel_tree p ON c.upstream_treatment_id = p.downstream_treatment_id - AND c.upstream_treatment_id != - ALL(p.path_info[0:array_upper(p.path_info, 1)-1]) + AND (p.path_info = ARRAY[]::integer[] OR + NOT (c.upstream_treatment_id = + ANY(p.path_info[0:array_upper(p.path_info, 1)-1])) + ) ) SELECT DISTINCT find_id, path_info, level FROM rel_tree ORDER BY find_id; @@ -364,9 +367,10 @@ class FindDownstreamTreatments(AbsFindTreatments): WITH RECURSIVE rel_tree AS ( SELECT id AS find_id, downstream_treatment_id, upstream_treatment_id, 1 AS level, - array[downstream_treatment_id] AS path_info + ARRAY[]::integer[] AS path_info FROM archaeological_finds_find - WHERE downstream_treatment_id is null + WHERE downstream_treatment_id is NULL AND + upstream_treatment_id is NOT NULL UNION ALL SELECT c.id AS find_id, c.downstream_treatment_id, c.upstream_treatment_id, @@ -374,8 +378,10 @@ class FindDownstreamTreatments(AbsFindTreatments): FROM archaeological_finds_find c JOIN rel_tree p ON c.downstream_treatment_id = p.upstream_treatment_id - AND c.downstream_treatment_id != - ALL(p.path_info[0:array_upper(p.path_info, 1)-1]) + AND (p.path_info = ARRAY[]::integer[] OR + NOT (c.downstream_treatment_id = + ANY(p.path_info[0:array_upper(p.path_info, 1)-1])) + ) ) SELECT DISTINCT find_id, path_info, level FROM rel_tree ORDER BY find_id; |
