satellite/metainfo/metabase: fix segment listing with cursor.Part

Change-Id: I910888d435b11d2d4687ea0042998a1078cd6443
This commit is contained in:
Egon Elbre 2020-11-24 15:31:57 +02:00
parent 67c210a64c
commit dad36179c6
2 changed files with 15 additions and 1 deletions

View File

@ -55,7 +55,7 @@ func (db *DB) ListSegments(ctx context.Context, opts ListSegments) (result ListS
FROM segments FROM segments
WHERE WHERE
stream_id = $1 AND stream_id = $1 AND
($2 = 0 OR position > $2) ($2 = 0::INT8 OR position > $2)
ORDER BY position ASC ORDER BY position ASC
LIMIT $3 LIMIT $3
`, opts.StreamID, opts.Cursor, opts.Limit+1))(func(rows tagsql.Rows) error { `, opts.StreamID, opts.Cursor, opts.Limit+1))(func(rows tagsql.Rows) error {

View File

@ -132,6 +132,20 @@ func TestListSegments(t *testing.T) {
}, },
}.Check(ctx, t, db) }.Check(ctx, t, db)
ListSegments{
Opts: metabase.ListSegments{
StreamID: obj.StreamID,
Limit: 2,
Cursor: metabase.SegmentPosition{
Part: 1,
Index: 10,
},
},
Result: metabase.ListSegmentsResult{
More: false,
},
}.Check(ctx, t, db)
Verify{ Verify{
Objects: []metabase.RawObject{ Objects: []metabase.RawObject{
metabase.RawObject(expectedObject), metabase.RawObject(expectedObject),