diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-02-27 12:39:04 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-02-27 12:39:04 +0100 |
commit | 2ca2a185b92b7680c7ef40267ed7568f3a323b76 (patch) | |
tree | d19c33c63233868d2c6ff958ba4c5ec6d544f658 /archaeological_finds/models_finds.py | |
parent | ea5150055203a014b4dc8fa6098634eb211a81b6 (diff) | |
download | Ishtar-2ca2a185b92b7680c7ef40267ed7568f3a323b76.tar.bz2 Ishtar-2ca2a185b92b7680c7ef40267ed7568f3a323b76.zip |
Operations: fix bulk update of finds and base finds for old postgresql version (refs #3472)
Diffstat (limited to 'archaeological_finds/models_finds.py')
-rw-r--r-- | archaeological_finds/models_finds.py | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index e99b43bc7..bf5ba6380 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -344,44 +344,48 @@ class BaseFind(BaseHistorizedItem, OwnPerms): sql = """ UPDATE "archaeological_finds_basefind" AS bf SET cache_short_id = - CASE basefind_cached_bulk_update.main_ope_code - WHEN NULL THEN - CASE basefind_cached_bulk_update.year - IS NOT NULL + CASE + WHEN basefind_cached_bulk_update.main_ope_code is NULL + THEN + CASE + WHEN basefind_cached_bulk_update.year + IS NOT NULL AND basefind_cached_bulk_update.ope_code - IS NOT NULL - WHEN TRUE THEN - '{ope_prefix}' || - basefind_cached_bulk_update.year || - '-' || - basefind_cached_bulk_update.ope_code - ELSE '' - END - ELSE - '{main_ope_prefix}' || - basefind_cached_bulk_update.main_ope_code + IS NOT NULL + THEN + '{ope_prefix}' || + basefind_cached_bulk_update.year || + '-' || + basefind_cached_bulk_update.ope_code + ELSE '' END + ELSE + '{main_ope_prefix}' || + basefind_cached_bulk_update.main_ope_code + END || '{join}' || to_char(basefind_cached_bulk_update.index, 'fm{zeros}'), - cache_complete_id = - CASE basefind_cached_bulk_update.main_ope_code - WHEN NULL THEN - CASE basefind_cached_bulk_update.year - IS NOT NULL + cache_complete_id = + CASE + WHEN basefind_cached_bulk_update.main_ope_code IS NULL + THEN + CASE + WHEN basefind_cached_bulk_update.year + IS NOT NULL AND basefind_cached_bulk_update.ope_code - IS NOT NULL - WHEN TRUE THEN - '{ope_prefix}' || - basefind_cached_bulk_update.year || - '-' || - basefind_cached_bulk_update.ope_code - ELSE '' - END - ELSE - '{main_ope_prefix}' || - basefind_cached_bulk_update.main_ope_code + IS NOT NULL + THEN + '{ope_prefix}' || + basefind_cached_bulk_update.year || + '-' || + basefind_cached_bulk_update.ope_code + ELSE '' END + ELSE + '{main_ope_prefix}' || + basefind_cached_bulk_update.main_ope_code + END || '{join}' || COALESCE( @@ -901,23 +905,25 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): sql = """ UPDATE "archaeological_finds_find" AS f SET cached_label = - CASE find_cached_bulk_update.main_ope_code - WHEN NULL THEN - CASE find_cached_bulk_update.year - IS NOT NULL + CASE + WHEN find_cached_bulk_update.main_ope_code is NULL + THEN + CASE + WHEN find_cached_bulk_update.year + IS NOT NULL AND find_cached_bulk_update.ope_code - IS NOT NULL - WHEN TRUE THEN - '{ope_prefix}' || - find_cached_bulk_update.year || - '-' || - find_cached_bulk_update.ope_code - ELSE '' - END - ELSE - '{main_ope_prefix}' || - find_cached_bulk_update.main_ope_code + IS NOT NULL + THEN + '{ope_prefix}' || + find_cached_bulk_update.year || + '-' || + find_cached_bulk_update.ope_code + ELSE '' END + ELSE + '{main_ope_prefix}' || + find_cached_bulk_update.main_ope_code + END || '-' || to_char(find_cached_bulk_update.index, 'fm{zeros}') || '{join}' || |