Closed willjleong closed 5 years ago
Thanks for your suggestion, it looks reasonable.
Would you mind sending a PR with implementation and additional test case to cover this scenario ? Or if you are not in a hurry, I can tackle this issue on the weekend : )
@pilagod Thanks, just submitted a PR with the proposed fix and a test case testing the change/fix.
Thanks, I have merged it and release v1.1.0 for this change.
Currently, if you pass the paginator
Paginate()
method a pointer to an slice of pointers to a struct model e.g.[]*User
there's an error thrown when encoding theID
s orCreatedAt
to cursors and getting thereflect: call of reflect.Value.FieldByName on ptr Value
.There should be a check before reflecting the gorm model to allow a slice of pointers to models to be cursor-paginated . This can be accomplished by checking to see if the key is a pointer or not and adding
Indirect()
when needed.Something like this but have not tested yet: