From aa0e8049657a6816d908ec035b4c6f1331d253e9 Mon Sep 17 00:00:00 2001 From: alemidev Date: Thu, 25 Aug 2022 20:15:04 +0200 Subject: [PATCH] fix: return None for missing keys --- src/treepuncher/storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/treepuncher/storage.py b/src/treepuncher/storage.py index 12c1200..09a1f19 100644 --- a/src/treepuncher/storage.py +++ b/src/treepuncher/storage.py @@ -34,7 +34,7 @@ class AddonStorage: # fstrings in queries are evil but if you go to this length to fuck up you kinda deserve it :) def get(self, key:str) -> Optional[Any]: res = self.db.cursor().execute(f"SELECT * FROM documents_{self.name} WHERE name = ?", (key,)).fetchall() - return json.loads(res[0][1]) + return json.loads(res[0][1]) if res else None def put(self, key:str, val:Any) -> None: cur = self.db.cursor()