mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-28 13:11:56 +00:00
Also give _execute() a description
This commit is contained in:
parent
099e4b88d8
commit
59a5f012cc
@ -495,8 +495,7 @@ class DataStore(RoomMemberStore, RoomStore,
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _get_min_token(self):
|
def _get_min_token(self):
|
||||||
row = yield self._execute(
|
row = yield self._execute(
|
||||||
None,
|
"_get_min_token", None, "SELECT MIN(stream_ordering) FROM events"
|
||||||
"SELECT MIN(stream_ordering) FROM events"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.min_token = row[0][0] if row and row[0] and row[0][0] else -1
|
self.min_token = row[0][0] if row and row[0] and row[0][0] else -1
|
||||||
|
@ -259,7 +259,7 @@ class SQLBaseStore(object):
|
|||||||
)
|
)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def _execute(self, decoder, query, *args):
|
def _execute(self, desc, decoder, query, *args):
|
||||||
"""Runs a single query for a result set.
|
"""Runs a single query for a result set.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -277,11 +277,10 @@ class SQLBaseStore(object):
|
|||||||
else:
|
else:
|
||||||
return cursor.fetchall()
|
return cursor.fetchall()
|
||||||
|
|
||||||
return self.runInteraction("_execute", interaction)
|
return self.runInteraction(desc, interaction)
|
||||||
|
|
||||||
def _execute_and_decode(self, desc, query, *args):
|
def _execute_and_decode(self, desc, query, *args):
|
||||||
# TODO: for now ignore desc
|
return self._execute(desc, self.cursor_to_dict, query, *args)
|
||||||
return self._execute(self.cursor_to_dict, query, *args)
|
|
||||||
|
|
||||||
# "Simple" SQL API methods that operate on a single table with no JOINs,
|
# "Simple" SQL API methods that operate on a single table with no JOINs,
|
||||||
# no complex WHERE clauses, just a dict of values for columns.
|
# no complex WHERE clauses, just a dict of values for columns.
|
||||||
|
@ -34,7 +34,7 @@ class PushRuleStore(SQLBaseStore):
|
|||||||
"WHERE user_name = ? "
|
"WHERE user_name = ? "
|
||||||
"ORDER BY priority_class DESC, priority DESC"
|
"ORDER BY priority_class DESC, priority DESC"
|
||||||
)
|
)
|
||||||
rows = yield self._execute(None, sql, user_name)
|
rows = yield self._execute("get_push_rules_for_user", None, sql, user_name)
|
||||||
|
|
||||||
dicts = []
|
dicts = []
|
||||||
for r in rows:
|
for r in rows:
|
||||||
|
@ -37,7 +37,8 @@ class PusherStore(SQLBaseStore):
|
|||||||
)
|
)
|
||||||
|
|
||||||
rows = yield self._execute(
|
rows = yield self._execute(
|
||||||
None, sql, app_id_and_pushkey[0], app_id_and_pushkey[1]
|
"get_pushers_by_app_id_and_pushkey", None, sql,
|
||||||
|
app_id_and_pushkey[0], app_id_and_pushkey[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
ret = [
|
ret = [
|
||||||
@ -70,7 +71,7 @@ class PusherStore(SQLBaseStore):
|
|||||||
"FROM pushers"
|
"FROM pushers"
|
||||||
)
|
)
|
||||||
|
|
||||||
rows = yield self._execute(None, sql)
|
rows = yield self._execute("get_all_pushers", None, sql)
|
||||||
|
|
||||||
ret = [
|
ret = [
|
||||||
{
|
{
|
||||||
|
@ -88,8 +88,7 @@ class RegistrationStore(SQLBaseStore):
|
|||||||
query = ("SELECT users.name, users.password_hash FROM users"
|
query = ("SELECT users.name, users.password_hash FROM users"
|
||||||
" WHERE users.name = ?")
|
" WHERE users.name = ?")
|
||||||
return self._execute(
|
return self._execute(
|
||||||
self.cursor_to_dict,
|
"get_user_by_id", self.cursor_to_dict, query, user_id
|
||||||
query, user_id
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_user_by_token(self, token):
|
def get_user_by_token(self, token):
|
||||||
|
@ -68,7 +68,7 @@ class RoomStore(SQLBaseStore):
|
|||||||
"""
|
"""
|
||||||
query = RoomsTable.select_statement("room_id=?")
|
query = RoomsTable.select_statement("room_id=?")
|
||||||
return self._execute(
|
return self._execute(
|
||||||
RoomsTable.decode_single_result, query, room_id,
|
"get_room", RoomsTable.decode_single_result, query, room_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
Loading…
Reference in New Issue
Block a user