mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-27 08:09:44 -05:00
pushers table requires a unique id.
This commit is contained in:
parent
806f380a8b
commit
ed26e4012b
@ -260,6 +260,7 @@ class SQLBaseStore(object):
|
|||||||
self._transaction_id_gen = IdGenerator("sent_transactions", "id", self)
|
self._transaction_id_gen = IdGenerator("sent_transactions", "id", self)
|
||||||
self._state_groups_id_gen = IdGenerator("state_groups", "id", self)
|
self._state_groups_id_gen = IdGenerator("state_groups", "id", self)
|
||||||
self._access_tokens_id_gen = IdGenerator("access_tokens", "id", self)
|
self._access_tokens_id_gen = IdGenerator("access_tokens", "id", self)
|
||||||
|
self._pushers_id_gen = IdGenerator("pushers", "id", self)
|
||||||
|
|
||||||
def start_profiling(self):
|
def start_profiling(self):
|
||||||
self._previous_loop_ts = self._clock.time_msec()
|
self._previous_loop_ts = self._clock.time_msec()
|
||||||
@ -423,20 +424,22 @@ class SQLBaseStore(object):
|
|||||||
|
|
||||||
txn.execute(sql, values.values())
|
txn.execute(sql, values.values())
|
||||||
|
|
||||||
def _simple_upsert(self, table, keyvalues, values, desc="_simple_upsert"):
|
def _simple_upsert(self, table, keyvalues, values,
|
||||||
|
insertion_values={}, desc="_simple_upsert"):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
table (str): The table to upsert into
|
table (str): The table to upsert into
|
||||||
keyvalues (dict): The unique key tables and their new values
|
keyvalues (dict): The unique key tables and their new values
|
||||||
values (dict): The nonunique columns and their new values
|
values (dict): The nonunique columns and their new values
|
||||||
|
insertion_values (dict): key/values to use when inserting
|
||||||
Returns: A deferred
|
Returns: A deferred
|
||||||
"""
|
"""
|
||||||
return self.runInteraction(
|
return self.runInteraction(
|
||||||
desc,
|
desc,
|
||||||
self._simple_upsert_txn, table, keyvalues, values
|
self._simple_upsert_txn, table, keyvalues, values, insertion_values,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _simple_upsert_txn(self, txn, table, keyvalues, values):
|
def _simple_upsert_txn(self, txn, table, keyvalues, values, insertion_values={}):
|
||||||
# Try to update
|
# Try to update
|
||||||
sql = "UPDATE %s SET %s WHERE %s" % (
|
sql = "UPDATE %s SET %s WHERE %s" % (
|
||||||
table,
|
table,
|
||||||
@ -455,6 +458,7 @@ class SQLBaseStore(object):
|
|||||||
allvalues = {}
|
allvalues = {}
|
||||||
allvalues.update(keyvalues)
|
allvalues.update(keyvalues)
|
||||||
allvalues.update(values)
|
allvalues.update(values)
|
||||||
|
allvalues.update(insertion_values)
|
||||||
|
|
||||||
sql = "INSERT INTO %s (%s) VALUES (%s)" % (
|
sql = "INSERT INTO %s (%s) VALUES (%s)" % (
|
||||||
table,
|
table,
|
||||||
|
@ -99,6 +99,7 @@ class PusherStore(SQLBaseStore):
|
|||||||
app_display_name, device_display_name,
|
app_display_name, device_display_name,
|
||||||
pushkey, pushkey_ts, lang, data):
|
pushkey, pushkey_ts, lang, data):
|
||||||
try:
|
try:
|
||||||
|
next_id = self._pushers_id_gen.get_next()
|
||||||
yield self._simple_upsert(
|
yield self._simple_upsert(
|
||||||
PushersTable.table_name,
|
PushersTable.table_name,
|
||||||
dict(
|
dict(
|
||||||
@ -115,6 +116,9 @@ class PusherStore(SQLBaseStore):
|
|||||||
lang=lang,
|
lang=lang,
|
||||||
data=data
|
data=data
|
||||||
),
|
),
|
||||||
|
insertion_values=dict(
|
||||||
|
id=next_id,
|
||||||
|
),
|
||||||
desc="add_pusher",
|
desc="add_pusher",
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user