diff options
author | Erik Johnston <erik@matrix.org> | 2015-03-24 16:17:39 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-03-24 16:17:39 +0000 |
commit | 9115421ace4cd6cd1080ab99c997994541aea30b (patch) | |
tree | 36a8f7095fcf578b0e8bb7a28481ce51581204df /synapse/storage | |
parent | Remove uses of REPLACE and ON CONFLICT IGNORE to make the SQL more portable. (diff) | |
download | synapse-9115421ace4cd6cd1080ab99c997994541aea30b.tar.xz |
Use _simple_upsert
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/__init__.py | 8 | ||||
-rw-r--r-- | synapse/storage/transactions.py | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py index 4877f45dce..e03d55b00d 100644 --- a/synapse/storage/__init__.py +++ b/synapse/storage/__init__.py @@ -81,14 +81,16 @@ class DataStore(RoomMemberStore, RoomStore, self._next_stream_id = int(hs.get_clock().time_msec()) * 1000 def insert_client_ip(self, user, access_token, device_id, ip, user_agent): - return self._simple_insert( + return self._simple_upsert( "user_ips", - { + keyvalues={ "user": user.to_string(), "access_token": access_token, - "device_id": device_id, "ip": ip, "user_agent": user_agent, + }, + values={ + "device_id": device_id, "last_seen": int(self._clock.time_msec()), }, desc="insert_client_ip", diff --git a/synapse/storage/transactions.py b/synapse/storage/transactions.py index 1a5bb41cb2..c6e00ae3fe 100644 --- a/synapse/storage/transactions.py +++ b/synapse/storage/transactions.py @@ -84,14 +84,14 @@ class TransactionStore(SQLBaseStore): def _set_received_txn_response(self, txn, transaction_id, origin, code, response_json): - self._simple_update_one_txn( + self._simple_upsert_txn( txn, table=ReceivedTransactionsTable.table_name, keyvalues={ "transaction_id": transaction_id, "origin": origin, }, - updatevalues={ + values={ "response_code": code, "response_json": response_json, } |