diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-04-27 14:45:51 +0100 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-04-27 15:10:10 +0100 |
commit | 6ee8507955f2b9674649acc928768b1a4d96f7c0 (patch) | |
tree | d73dc2181f16c97f942839a708ec8bcc0410f40b | |
parent | f023cdf8c42cc1a4bb850b478dbbf7d901b5e1bd (diff) |
Correct account data position mapping
-rw-r--r-- | syncapi/storage/postgres/account_data_table.go | 10 | ||||
-rw-r--r-- | syncapi/storage/sqlite3/account_data_table.go | 11 |
2 files changed, 14 insertions, 7 deletions
diff --git a/syncapi/storage/postgres/account_data_table.go b/syncapi/storage/postgres/account_data_table.go index ec1919fc..7c0d0303 100644 --- a/syncapi/storage/postgres/account_data_table.go +++ b/syncapi/storage/postgres/account_data_table.go @@ -105,7 +105,7 @@ func (s *accountDataStatements) SelectAccountDataInRange( accountDataEventFilter *gomatrixserverlib.EventFilter, ) (data map[string][]string, pos types.StreamPosition, err error) { data = make(map[string][]string) - pos = r.Low() + pos = r.High() rows, err := s.selectAccountDataInRangeStmt.QueryContext(ctx, userID, r.Low(), r.High(), pq.StringArray(filterConvertTypeWildcardToSQL(accountDataEventFilter.Types)), @@ -120,6 +120,7 @@ func (s *accountDataStatements) SelectAccountDataInRange( var dataType string var roomID string var id types.StreamPosition + var highest types.StreamPosition for rows.Next() { if err = rows.Scan(&id, &roomID, &dataType); err != nil { @@ -131,10 +132,13 @@ func (s *accountDataStatements) SelectAccountDataInRange( } else { data[roomID] = []string{dataType} } - if id > pos { - pos = id + if id > highest { + highest = id } } + if highest < pos { + pos = highest + } return data, pos, rows.Err() } diff --git a/syncapi/storage/sqlite3/account_data_table.go b/syncapi/storage/sqlite3/account_data_table.go index 2c7272ea..1bbfe9c9 100644 --- a/syncapi/storage/sqlite3/account_data_table.go +++ b/syncapi/storage/sqlite3/account_data_table.go @@ -96,7 +96,7 @@ func (s *accountDataStatements) SelectAccountDataInRange( r types.Range, filter *gomatrixserverlib.EventFilter, ) (data map[string][]string, pos types.StreamPosition, err error) { - pos = r.Low() + pos = r.High() data = make(map[string][]string) stmt, params, err := prepareWithFilters( s.db, nil, selectAccountDataInRangeSQL, @@ -116,6 +116,7 @@ func (s *accountDataStatements) SelectAccountDataInRange( var dataType string var roomID string var id types.StreamPosition + var highest types.StreamPosition for rows.Next() { if err = rows.Scan(&id, &roomID, &dataType); err != nil { @@ -127,11 +128,13 @@ func (s *accountDataStatements) SelectAccountDataInRange( } else { data[roomID] = []string{dataType} } - if id > pos { - pos = id + if id > highest { + highest = id } } - + if highest < pos { + pos = highest + } return data, pos, nil } |