mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-06 14:33:10 -06:00
Fix off-by-one error
This commit is contained in:
parent
148a868b04
commit
cf20835436
|
|
@ -37,7 +37,7 @@ const selectEventsSQL = "" +
|
|||
"SELECT event_json FROM output_room_events WHERE event_id = ANY($1)"
|
||||
|
||||
const selectEventsInRangeSQL = "" +
|
||||
"SELECT event_json FROM output_room_events WHERE id >= $1 AND id <= $2"
|
||||
"SELECT event_json FROM output_room_events WHERE id > $1 AND id <= $2"
|
||||
|
||||
const selectMaxIDSQL = "" +
|
||||
"SELECT MAX(id) FROM output_room_events"
|
||||
|
|
@ -96,8 +96,8 @@ func (s *outputRoomEventsStatements) InRange(oldPos, newPos int64) ([]gomatrixse
|
|||
}
|
||||
result = append(result, ev)
|
||||
}
|
||||
// Expect one event per position, inclusive eg old=3, new=5, expect 3,4,5 so 3 events.
|
||||
wantNum := (1 + newPos - oldPos)
|
||||
// Expect one event per position, exclusive of old. eg old=3, new=5, expect 4,5 so 2 events.
|
||||
wantNum := (newPos - oldPos)
|
||||
if i != wantNum {
|
||||
return nil, fmt.Errorf("failed to map all positions to events: (got %d, wanted, %d)", i, wantNum)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ func (d *SyncServerDatabase) SyncStreamPosition() (int64, error) {
|
|||
return d.events.MaxID()
|
||||
}
|
||||
|
||||
// EventsInRange returns all events in the given range, inclusive.
|
||||
// EventsInRange returns all events in the given range, exclusive of oldPos, inclusive of newPos.
|
||||
func (d *SyncServerDatabase) EventsInRange(oldPos, newPos int64) ([]gomatrixserverlib.Event, error) {
|
||||
return d.events.InRange(oldPos, newPos)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue