summaryrefslogtreecommitdiff
path: root/archaeological_context_records/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r--archaeological_context_records/models.py37
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}
);