aboutsummaryrefslogtreecommitdiff
path: root/syncapi/storage
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2021-02-04 11:45:49 +0000
committerGitHub <noreply@github.com>2021-02-04 11:45:49 +0000
commitb7e3b81a22775697ad8ff463247d83077ea6cbe3 (patch)
treefbb5a778585ec811d2dd558abff2afc9a020003a /syncapi/storage
parentde5f22a46960308b3fe8efe7ca1813460b2c9c09 (diff)
Fix ON CONFLICT on sync API account data (#1745) (#1750)
Diffstat (limited to 'syncapi/storage')
-rw-r--r--syncapi/storage/postgres/account_data_table.go2
-rw-r--r--syncapi/storage/sqlite3/account_data_table.go4
2 files changed, 3 insertions, 3 deletions
diff --git a/syncapi/storage/postgres/account_data_table.go b/syncapi/storage/postgres/account_data_table.go
index 67eb1e86..25bdb1da 100644
--- a/syncapi/storage/postgres/account_data_table.go
+++ b/syncapi/storage/postgres/account_data_table.go
@@ -53,7 +53,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS syncapi_account_data_id_idx ON syncapi_account
const insertAccountDataSQL = "" +
"INSERT INTO syncapi_account_data_type (user_id, room_id, type) VALUES ($1, $2, $3)" +
" ON CONFLICT ON CONSTRAINT syncapi_account_data_unique" +
- " DO UPDATE SET id = EXCLUDED.id" +
+ " DO UPDATE SET id = nextval('syncapi_stream_id')" +
" RETURNING id"
const selectAccountDataInRangeSQL = "" +
diff --git a/syncapi/storage/sqlite3/account_data_table.go b/syncapi/storage/sqlite3/account_data_table.go
index 1c65cb6a..24c44224 100644
--- a/syncapi/storage/sqlite3/account_data_table.go
+++ b/syncapi/storage/sqlite3/account_data_table.go
@@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS syncapi_account_data_type (
const insertAccountDataSQL = "" +
"INSERT INTO syncapi_account_data_type (id, user_id, room_id, type) VALUES ($1, $2, $3, $4)" +
" ON CONFLICT (user_id, room_id, type) DO UPDATE" +
- " SET id = EXCLUDED.id"
+ " SET id = $5"
const selectAccountDataInRangeSQL = "" +
"SELECT room_id, type FROM syncapi_account_data_type" +
@@ -86,7 +86,7 @@ func (s *accountDataStatements) InsertAccountData(
if err != nil {
return
}
- _, err = sqlutil.TxStmt(txn, s.insertAccountDataStmt).ExecContext(ctx, pos, userID, roomID, dataType)
+ _, err = sqlutil.TxStmt(txn, s.insertAccountDataStmt).ExecContext(ctx, pos, userID, roomID, dataType, pos)
return
}