diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-02-27 12:33:14 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-02-27 12:33:14 +0100 |
commit | 73eba61cfdb5011a5c8001d6f1d22e079b9e186c (patch) | |
tree | 4d0daee448a5d8868685f90a23d1671579fd3609 /archaeological_context_records/models.py | |
parent | b684b098c382ed19c7ed8889e050f0ef196c2b54 (diff) | |
download | Ishtar-73eba61cfdb5011a5c8001d6f1d22e079b9e186c.tar.bz2 Ishtar-73eba61cfdb5011a5c8001d6f1d22e079b9e186c.zip |
Operations: fix bulk update of context records for old postgresql version (refs #3472)
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r-- | archaeological_context_records/models.py | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index c45cb1fd4..1ec32ea83 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -290,30 +290,33 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms, sql = """ UPDATE "archaeological_context_records_contextrecord" AS cr SET cached_label = - CASE context_records_cached_label_bulk_update.main_code - WHEN NULL THEN - CASE context_records_cached_label_bulk_update.year - IS NOT NULL - AND context_records_cached_label_bulk_update.ope_code - IS NOT NULL - WHEN TRUE THEN - '{ope_prefix}' || - context_records_cached_label_bulk_update.year || - '-' || - context_records_cached_label_bulk_update.ope_code - ELSE '' - END - ELSE - '{main_ope_prefix}' || - context_records_cached_label_bulk_update.main_code + CASE + WHEN context_records_cached_label_bulk_update.main_code + IS NULL + THEN + CASE + WHEN context_records_cached_label_bulk_update.year + IS NOT NULL + AND context_records_cached_label_bulk_update.ope_code + IS NOT NULL + THEN + '{ope_prefix}' || + context_records_cached_label_bulk_update.year || + '-' || + context_records_cached_label_bulk_update.ope_code + ELSE '' END + ELSE + '{main_ope_prefix}' || + context_records_cached_label_bulk_update.main_code + END || '{join}' || context_records_cached_label_bulk_update.section || '{join}' || context_records_cached_label_bulk_update.number || '{join}' || context_records_cached_label_bulk_update.label FROM context_records_cached_label_bulk_update WHERE cr.id = context_records_cached_label_bulk_update.id - AND cr.id IN ( + AND cr.id IN ( SELECT id FROM archaeological_context_records_contextrecord WHERE {where} ); |