From eb4e38102281e43eb5579c59c1d1e3d409dfbe8e Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 22 Jul 2023 17:16:56 -0700 Subject: [PATCH] Check object_cache is None before pulling row id. --- voussoirkit/worms.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/voussoirkit/worms.py b/voussoirkit/worms.py index f3978f9..aa0ffcb 100644 --- a/voussoirkit/worms.py +++ b/voussoirkit/worms.py @@ -651,15 +651,16 @@ class DatabaseWithCaching(Database, metaclass=abc.ABCMeta): object_table = object_class.table object_cache = self.caches.get(object_class, None) + if object_cache is None: + log.loud('The %s table is not cached. Returning new instance.', object_class.table) + return object_class(self, db_row) + if isinstance(db_row, (dict, sqlite3.Row)): object_id = db_row['id'] else: object_index = self.COLUMN_INDEX[object_table] object_id = db_row[object_index['id']] - if object_cache is None: - return object_class(self, db_row) - try: instance = object_cache[object_id] except KeyError: