fix: return None for missing keys

This commit is contained in:
əlemi 2022-08-25 20:15:04 +02:00
parent b750aa140f
commit aa0e804965
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

@ -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()