Skip to content

Commit ce794fc

Browse files
committed
fix: internal pagination
1 parent ce21381 commit ce794fc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

internal/storage/common/cursor.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func Extract[OF any](
2727
}
2828
}
2929

30-
func unmarshalCursor[OF any](v string, modifiers ...func(query *InitialPaginatedQuery[OF]) error) (PaginatedQuery[OF], error) {
30+
func unmarshalCursor[Options any](v string, modifiers ...func(query *InitialPaginatedQuery[Options]) error) (PaginatedQuery[Options], error) {
3131
res, err := base64.RawURLEncoding.DecodeString(v)
3232
if err != nil {
3333
return nil, err
@@ -42,22 +42,22 @@ func unmarshalCursor[OF any](v string, modifiers ...func(query *InitialPaginated
4242
return nil, fmt.Errorf("invalid cursor: %w", err)
4343
}
4444

45-
var q PaginatedQuery[OF]
45+
var q PaginatedQuery[Options]
4646
if x.Offset != nil { // Offset defined, this is an offset cursor
47-
q = &OffsetPaginatedQuery[OF]{}
47+
q = &OffsetPaginatedQuery[Options]{}
4848
} else {
49-
q = &ColumnPaginatedQuery[OF]{}
49+
q = &ColumnPaginatedQuery[Options]{}
5050
}
5151

5252
if err := json.Unmarshal(res, &q); err != nil {
5353
return nil, err
5454
}
5555

56-
var root *InitialPaginatedQuery[OF]
56+
var root *InitialPaginatedQuery[Options]
5757
if x.Offset != nil { // Offset defined, this is an offset cursor
58-
root = &q.(*OffsetPaginatedQuery[OF]).InitialPaginatedQuery
58+
root = &q.(*OffsetPaginatedQuery[Options]).InitialPaginatedQuery
5959
} else {
60-
root = &q.(*ColumnPaginatedQuery[OF]).InitialPaginatedQuery
60+
root = &q.(*ColumnPaginatedQuery[Options]).InitialPaginatedQuery
6161
}
6262

6363
for _, modifier := range modifiers {
@@ -66,7 +66,7 @@ func unmarshalCursor[OF any](v string, modifiers ...func(query *InitialPaginated
6666
}
6767
}
6868

69-
return reflect.ValueOf(q).Elem().Interface().(PaginatedQuery[OF]), nil
69+
return reflect.ValueOf(q).Elem().Interface().(PaginatedQuery[Options]), nil
7070
}
7171

7272
func Iterate[OF any, Options any](
@@ -91,7 +91,7 @@ func Iterate[OF any, Options any](
9191
break
9292
}
9393

94-
query, err = unmarshalCursor[OF](cursor.Next)
94+
query, err = unmarshalCursor[Options](cursor.Next)
9595
if err != nil {
9696
return fmt.Errorf("paginating next request: %w", err)
9797
}

0 commit comments

Comments
 (0)