From 4ee2ef0c6d7762f56be362380e114dd3a9654b9a Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Sat, 17 May 2025 19:23:52 +0200 Subject: [PATCH] Backport https://github.com/neilalexander/harmony/commit/1d409dede69266959c4d992738e65d3ad490508a --- syncapi/storage/postgres/account_data_table.go | 3 ++- syncapi/storage/sqlite3/account_data_table.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/syncapi/storage/postgres/account_data_table.go b/syncapi/storage/postgres/account_data_table.go index e4b558ff..c8feaa6a 100644 --- a/syncapi/storage/postgres/account_data_table.go +++ b/syncapi/storage/postgres/account_data_table.go @@ -92,6 +92,7 @@ func (s *accountDataStatements) SelectAccountDataInRange( accountDataEventFilter *synctypes.EventFilter, ) (data map[string][]string, pos types.StreamPosition, err error) { data = make(map[string][]string) + pos = r.Low() rows, err := sqlutil.TxStmt(txn, s.selectAccountDataInRangeStmt).QueryContext( ctx, userID, r.Low(), r.High(), @@ -122,7 +123,7 @@ func (s *accountDataStatements) SelectAccountDataInRange( pos = id } } - if pos == 0 { + if len(data) == 0 { pos = r.High() } return data, pos, rows.Err() diff --git a/syncapi/storage/sqlite3/account_data_table.go b/syncapi/storage/sqlite3/account_data_table.go index b98cf227..a84deb87 100644 --- a/syncapi/storage/sqlite3/account_data_table.go +++ b/syncapi/storage/sqlite3/account_data_table.go @@ -84,6 +84,8 @@ func (s *accountDataStatements) SelectAccountDataInRange( filter *synctypes.EventFilter, ) (data map[string][]string, pos types.StreamPosition, err error) { data = make(map[string][]string) + pos = r.Low() + stmt, params, err := prepareWithFilters( s.db, txn, selectAccountDataInRangeSQL, []interface{}{ @@ -119,7 +121,7 @@ func (s *accountDataStatements) SelectAccountDataInRange( pos = id } } - if pos == 0 { + if len(data) == 0 { pos = r.High() } return data, pos, rows.Err()