fix database.user_settings.find logic

This commit is contained in:
jesopo 2019-12-01 07:05:01 +00:00
parent cdfbf6f002
commit b385323386

View file

@ -211,9 +211,9 @@ class UserSettings(Table):
return values return values
return default return default
def find(self, user_id: int, pattern: str, default: typing.Any=[]): def find(self, user_id: int, pattern: str, default: typing.Any=[]):
values = self.database.execute( values = self.database.execute_fetchall(
"""SELECT setting, value FROM user_settings WHERE """SELECT setting, value FROM user_settings WHERE
user_id=? AND setting LIKE '?'""", [user_id, pattern.lower()]) user_id=? AND setting LIKE ?""", [user_id, pattern.lower()])
if values: if values:
for i, value in enumerate(values): for i, value in enumerate(values):
values[i] = value[0], json.loads(value[1]) values[i] = value[0], json.loads(value[1])
@ -246,7 +246,7 @@ class UserChannelSettings(Table):
default: typing.Any=[]): default: typing.Any=[]):
values = self.database.execute_fetchall( values = self.database.execute_fetchall(
"""SELECT setting, value FROM user_channel_settings WHERE """SELECT setting, value FROM user_channel_settings WHERE
user_id=? AND channel_id=? AND setting LIKE '?'""", user_id=? AND channel_id=? AND setting LIKE ?""",
[user_id, channel_id, pattern.lower()]) [user_id, channel_id, pattern.lower()])
if values: if values:
for i, value in enumerate(values): for i, value in enumerate(values):