Conversation
|
• The change introduces a regression in default pagination behavior: with nil or partial options, PrepareQuery now discards non‑zero page.Size values and applies an unintended default limit/offset. This will Review comment:
|
…gination edge case tests
|
Sorry, a new one now: • The new defaulting logic in PrepareQuery can leave page.Size inconsistent with the actual LIMIT when Review comment:
|
|
• There is a behavioral inconsistency in the new pagination defaults: getDefaults can reduce the effective default page size when DefaultSize exceeds MaxSize unless options are normalized via NewPaginator, which Review comment:
|
| func (m *Mapper) TraversalsByName(t reflect.Type, names []string) [][]int { | ||
| r := make([][]int, 0, len(names)) | ||
| m.TraversalsByNameFunc(t, names, func(_ int, i []int) error { | ||
| _ = m.TraversalsByNameFunc(t, names, func(_ int, i []int) error { |
There was a problem hiding this comment.
It's to signal the linter you are explicitly ignoring the error
Page size is limited by the constant in the codebase (50). This prevents higher page sizes, even when specified by a paginator. It also removes some generics that are not needed
This pull request refactors the paginator implementation to simplify configuration and improve clarity. The main change is replacing the functional options pattern with a
PaginatorOptionsstruct, which centralizes configuration for default page size, max size, sort order, and column transformation. All paginator methods and tests are updated to use this new struct, resulting in more straightforward and maintainable code.Paginator configuration refactor:
WithDefaultSize,WithMaxSize, etc.) with a singlePaginatorOptionsstruct that holds all configuration, includingDefaultSize,MaxSize,Sort, andColumnFunc. TheNewPaginatorfunction now takes a pointer toPaginatorOptionsinstead of variadic option functions. (page.go)Limit,Offset, etc.) to accept a*PaginatorOptionsparameter, ensuring they use the correct configuration values from the struct. (page.go)Paginator logic updates:
PrepareQuery,PrepareRaw, andPrepareResultto use the new options struct for determining limits, offsets, and sorting, ensuring consistent behavior. (page.go) [1] [2]Test updates:
PaginatorOptionsstruct instead of the old functional options, improving readability and alignment with the new API. (page_test.go) [1] [2] [3] [4] [5]