From eaa3c7ac6f6d87243472c22e5a14f35708a937bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 15 Sep 2024 12:23:43 +0200 Subject: [PATCH] Continued: - these DELETE SQL statements have already been encapsulated --- fba/commands.py | 4 ++-- fba/models/blocks.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fba/commands.py b/fba/commands.py index 091ac99..6726b02 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -2071,8 +2071,8 @@ def remove_invalid(args: argparse.Namespace) -> int: logger.debug("row[domain]='%s'", row["domain"]) if not validators.domain(row["domain"].split("/")[0], rfc_2782=True): logger.info("Invalid row[domain]='%s' found, removing ...", row["domain"]) - database.cursor.execute("DELETE FROM blocks WHERE blocker = ? OR blocked = ?", [row["domain"], row["domain"]]) - database.cursor.execute("DELETE FROM instances WHERE domain = ? LIMIT 1", [row["domain"]]) + blocks.delete(row["domain"]) + instances.delete(row["domain"]) logger.debug("Invoking commit() ...") database.connection.commit() diff --git a/fba/models/blocks.py b/fba/models/blocks.py index d3e93a3..2ad3fd6 100644 --- a/fba/models/blocks.py +++ b/fba/models/blocks.py @@ -280,8 +280,7 @@ def delete(domain: str) -> None: logger.debug("domain='%s' - CALLED!", domain) domain_helper.raise_on(domain) - database.cursor.execute(f"DELETE FROM blocks WHERE blocker = ?", [domain]) - database.cursor.execute(f"DELETE FROM blocks WHERE blocked = ?", [domain]) + database.cursor.execute(f"DELETE FROM blocks WHERE blocker = ? OR blocked = ?", [domain, domain]) logger.debug("Invoking commit() ...") database.connection.commit() -- 2.39.5