diff --git a/syncapi/storage/cosmosdb/account_data_table.go b/syncapi/storage/cosmosdb/account_data_table.go index 36ee845e4..55fffdd42 100644 --- a/syncapi/storage/cosmosdb/account_data_table.go +++ b/syncapi/storage/cosmosdb/account_data_table.go @@ -130,11 +130,6 @@ func (s *accountDataStatements) InsertAccountData( // " ON CONFLICT (user_id, room_id, type) DO UPDATE" + // " SET id = $5" - pos, err = s.streamIDStatements.nextAccountDataID(ctx, txn) - if err != nil { - return - } - // UNIQUE (user_id, room_id, type) // roomId can be NULL docId := fmt.Sprintf("%s,%s,%s", userID, cosmosdbapi.EnsureIdPart(roomID), dataType) @@ -143,8 +138,12 @@ func (s *accountDataStatements) InsertAccountData( dbData, _ := getAccountDataType(s, ctx, s.getPartitionKey(), cosmosDocId) if dbData != nil { dbData.SetUpdateTime() - dbData.AccountDataType.ID = int64(pos) } else { + pos, err = s.streamIDStatements.nextAccountDataID(ctx, txn) + if err != nil { + return + } + data := accountDataTypeCosmos{ ID: int64(pos), UserID: userID, @@ -243,7 +242,7 @@ func (s *accountDataStatements) SelectMaxAccountDataID( // "SELECT MAX(id) FROM syncapi_account_data_type" - var nullableID sql.NullInt64 + // var nullableID sql.NullInt64 // err = sqlutil.TxStmt(txn, s.selectMaxAccountDataIDStmt).QueryRowContext(ctx).Scan(&nullableID) params := map[string]interface{}{ "@x1": s.getCollectionName(), @@ -258,11 +257,12 @@ func (s *accountDataStatements) SelectMaxAccountDataID( s.selectMaxAccountDataIDStmt, params, &rows) if err != cosmosdbutil.ErrNoRows && len(rows) == 1 { - nullableID.Int64 = rows[0].Number + id = rows[0].Number + } - if nullableID.Valid { - id = nullableID.Int64 - } + // if nullableID.Valid { + // id = nullableID.Int64 + // } return } diff --git a/syncapi/storage/cosmosdb/invites_table.go b/syncapi/storage/cosmosdb/invites_table.go index a25efb8a1..214bf6625 100644 --- a/syncapi/storage/cosmosdb/invites_table.go +++ b/syncapi/storage/cosmosdb/invites_table.go @@ -287,7 +287,7 @@ func (s *inviteEventsStatements) SelectInviteEventsInRange( func (s *inviteEventsStatements) SelectMaxInviteID( ctx context.Context, txn *sql.Tx, ) (id int64, err error) { - var nullableID sql.NullInt64 + // var nullableID sql.NullInt64 // "SELECT MAX(id) FROM syncapi_invite_events" @@ -306,11 +306,11 @@ func (s *inviteEventsStatements) SelectMaxInviteID( s.selectMaxInviteIDStmt, params, &rows) if len(rows) > 0 { - nullableID.Int64 = rows[0].Max + id = rows[0].Max } - if nullableID.Valid { - id = nullableID.Int64 - } + // if nullableID.Valid { + // id = nullableID.Int64 + // } return } diff --git a/syncapi/storage/cosmosdb/peeks_table.go b/syncapi/storage/cosmosdb/peeks_table.go index 5db726889..9162b8f71 100644 --- a/syncapi/storage/cosmosdb/peeks_table.go +++ b/syncapi/storage/cosmosdb/peeks_table.go @@ -377,7 +377,7 @@ func (s *peekStatements) SelectMaxPeekID( // "SELECT MAX(id) FROM syncapi_peeks" // stmt := sqlutil.TxStmt(txn, s.selectMaxPeekIDStmt) - var nullableID sql.NullInt64 + // var nullableID sql.NullInt64 params := map[string]interface{}{ "@x1": s.getCollectionName(), } @@ -392,11 +392,11 @@ func (s *peekStatements) SelectMaxPeekID( // err = stmt.QueryRowContext(ctx).Scan(&nullableID) if rows != nil { - nullableID.Int64 = rows[0].Max + id = rows[0].Max } - if nullableID.Valid { - id = nullableID.Int64 - } + // if nullableID.Valid { + // id = nullableID.Int64 + // } return } diff --git a/syncapi/storage/cosmosdb/receipt_table.go b/syncapi/storage/cosmosdb/receipt_table.go index 4ce868ddc..2504cbf15 100644 --- a/syncapi/storage/cosmosdb/receipt_table.go +++ b/syncapi/storage/cosmosdb/receipt_table.go @@ -203,7 +203,7 @@ func (r *receiptStatements) SelectRoomReceiptsAfter(ctx context.Context, roomIDs func (s *receiptStatements) SelectMaxReceiptID( ctx context.Context, txn *sql.Tx, ) (id int64, err error) { - var nullableID sql.NullInt64 + // var nullableID sql.NullInt64 // "SELECT MAX(id) FROM syncapi_receipts" @@ -221,11 +221,11 @@ func (s *receiptStatements) SelectMaxReceiptID( // stmt := sqlutil.TxStmt(txn, s.selectMaxReceiptID) if rows != nil { - nullableID.Int64 = rows[0].Max + id = rows[0].Max } // err = stmt.QueryRowContext(ctx).Scan(&nullableID) - if nullableID.Valid { - id = nullableID.Int64 - } + // if nullableID.Valid { + // id = nullableID.Int64 + // } return } diff --git a/syncapi/storage/cosmosdb/send_to_device_table.go b/syncapi/storage/cosmosdb/send_to_device_table.go index ec0793edc..f70c3bf4e 100644 --- a/syncapi/storage/cosmosdb/send_to_device_table.go +++ b/syncapi/storage/cosmosdb/send_to_device_table.go @@ -268,7 +268,7 @@ func (s *sendToDeviceStatements) DeleteSendToDeviceMessages( func (s *sendToDeviceStatements) SelectMaxSendToDeviceMessageID( ctx context.Context, txn *sql.Tx, ) (id int64, err error) { - var nullableID sql.NullInt64 + // var nullableID sql.NullInt64 // "SELECT MAX(id) FROM syncapi_send_to_device" params := map[string]interface{}{ @@ -286,11 +286,11 @@ func (s *sendToDeviceStatements) SelectMaxSendToDeviceMessageID( // err = stmt.QueryRowContext(ctx).Scan(&nullableID) if rows != nil { - nullableID.Int64 = rows[0].Max + id = rows[0].Max } - if nullableID.Valid { - id = nullableID.Int64 - } + // if nullableID.Valid { + // id = nullableID.Int64 + // } return }