Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch exception in case of missing ds table #34595

Merged
merged 6 commits into from
May 30, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions corehq/apps/userreports/sql/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,14 @@ def bulk_delete(self, docs, use_shard_col=True):
table = self.get_table()
doc_ids = [doc['_id'] for doc in docs]
delete = table.delete(table.c.doc_id.in_(doc_ids))
with self.session_context() as session:
session.execute(delete)
try:
with self.session_context() as session:
session.execute(delete)
except ProgrammingError as e:
if not self.table_exists:
return
else:
raise e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Just noting that the else here is redundant. And a comment could be useful.

if not self.table_exists:  # ignore error if table is missing
   return
raise e


register_data_source_row_change(
domain=self.config.domain,
Expand Down
Loading