Skip to content

Commit 6a52eaf

Browse files
committed
update promotion code to treat empty stings and null values as meaningful
1 parent eddad84 commit 6a52eaf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sde_collections/models/collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,18 @@ def promote_to_curated(self):
211211
continue
212212

213213
delta_value = getattr(delta, field_name)
214-
if delta_value not in [None, ""] and getattr(curated, field_name) != delta_value:
214+
if getattr(curated, field_name) != delta_value:
215215
updated_fields[field_name] = delta_value
216216

217217
if updated_fields:
218218
CuratedUrl.objects.filter(pk=curated.pk).update(**updated_fields)
219219
else:
220-
# If no matching CuratedUrl, create a new one using all non-null and non-empty fields
220+
# Previously, we excluded fields with values of None and ""
221+
# however, such null values are considered meaningful and should be copied over
221222
new_data = {
222223
field.name: getattr(delta, field.name)
223224
for field in delta._meta.fields
224-
if field.name not in ["to_delete", "collection", "id"]
225-
and getattr(delta, field.name) not in [None, ""]
225+
if field.name not in ["to_delete", "collection", "id"] and getattr(delta, field.name)
226226
}
227227
CuratedUrl.objects.create(collection=self, **new_data)
228228

0 commit comments

Comments
 (0)