fix: return None for missing keys
This commit is contained in:
parent
b750aa140f
commit
aa0e804965
1 changed files with 1 additions and 1 deletions
|
@ -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 :)
|
# 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]:
|
def get(self, key:str) -> Optional[Any]:
|
||||||
res = self.db.cursor().execute(f"SELECT * FROM documents_{self.name} WHERE name = ?", (key,)).fetchall()
|
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:
|
def put(self, key:str, val:Any) -> None:
|
||||||
cur = self.db.cursor()
|
cur = self.db.cursor()
|
||||||
|
|
Loading…
Reference in a new issue