Use _simple_upsert

This commit is contained in:
Erik Johnston 2015-03-24 16:17:39 +00:00
parent 6e7131f02f
commit 9115421ace
2 changed files with 7 additions and 5 deletions

View File

@ -81,14 +81,16 @@ class DataStore(RoomMemberStore, RoomStore,
self._next_stream_id = int(hs.get_clock().time_msec()) * 1000 self._next_stream_id = int(hs.get_clock().time_msec()) * 1000
def insert_client_ip(self, user, access_token, device_id, ip, user_agent): def insert_client_ip(self, user, access_token, device_id, ip, user_agent):
return self._simple_insert( return self._simple_upsert(
"user_ips", "user_ips",
{ keyvalues={
"user": user.to_string(), "user": user.to_string(),
"access_token": access_token, "access_token": access_token,
"device_id": device_id,
"ip": ip, "ip": ip,
"user_agent": user_agent, "user_agent": user_agent,
},
values={
"device_id": device_id,
"last_seen": int(self._clock.time_msec()), "last_seen": int(self._clock.time_msec()),
}, },
desc="insert_client_ip", desc="insert_client_ip",

View File

@ -84,14 +84,14 @@ class TransactionStore(SQLBaseStore):
def _set_received_txn_response(self, txn, transaction_id, origin, code, def _set_received_txn_response(self, txn, transaction_id, origin, code,
response_json): response_json):
self._simple_update_one_txn( self._simple_upsert_txn(
txn, txn,
table=ReceivedTransactionsTable.table_name, table=ReceivedTransactionsTable.table_name,
keyvalues={ keyvalues={
"transaction_id": transaction_id, "transaction_id": transaction_id,
"origin": origin, "origin": origin,
}, },
updatevalues={ values={
"response_code": code, "response_code": code,
"response_json": response_json, "response_json": response_json,
} }