Closed khalilsarwari closed 3 years ago
Yes, you're right. Currently context is automatically default to background context at here:
I didn't consider the custom context use case. I think we should let user decide their own context instead of providing a default one. Please give me some time to do testing for these scenarios.
@khalilsarwari Thanks for your finding, this is an important case 💪
@khalilsarwari I have removed the context overridden line and release a new version v2.1.0. You can upgrade package and try to see if it solves the problem. 😃
Although clients now can use their own custom context, they also take the responsibility to manage db session between different query session. Refer to document for more details https://gorm.io/docs/method_chaining.html#Method-Chain-Safety-Goroutine-Safety
Thanks again for this significant finding! 💪
Hi,
If I am using context for the query I would like to paginate, it currently does not get passed on I believe.
For example,
I have something in
ctx
that is needed in the AfterFind of Car, and I think the pagination is replacing thectx
with anotherctx
?