From 96691c3b2a623b7350b6b2aee94d1bf03dcd3638 Mon Sep 17 00:00:00 2001 From: Samuel Bray Date: Mon, 22 Apr 2024 14:50:49 -0700 Subject: [PATCH] Fix bug on empty delete in merge table (#940) * fix bug on empty delete in merge table * update changelog * fix spelling --------- Co-authored-by: Chris Brozdowski --- CHANGELOG.md | 2 ++ src/spyglass/utils/dj_merge_tables.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b4f579ae..d6eda918e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ - Prioritize datajoint filepath entry for defining abs_path of analysis nwbfile #918 - Fix potential duplicate entries in Merge part tables #922 +- Add logging of AnalysisNwbfile creation time and size #937 +- Fix error on empty delete call in merge table. #940 - Add log of AnalysisNwbfile creation time, size, and access count #937, #941 ### Pipelines diff --git a/src/spyglass/utils/dj_merge_tables.py b/src/spyglass/utils/dj_merge_tables.py index f94645ccf..2b8aab5ef 100644 --- a/src/spyglass/utils/dj_merge_tables.py +++ b/src/spyglass/utils/dj_merge_tables.py @@ -799,11 +799,16 @@ def merge_populate(self, source: str, keys=None): def delete(self, force_permission=False, *args, **kwargs): """Alias for cautious_delete, overwrites datajoint.table.Table.delete""" - for part in self.merge_get_part( - restriction=self.restriction, - multi_source=True, - return_empties=False, + if not ( + parts := self.merge_get_part( + restriction=self.restriction, + multi_source=True, + return_empties=False, + ) ): + return + + for part in parts: part.delete(force_permission=force_permission, *args, **kwargs) def super_delete(self, warn=True, *args, **kwargs):