Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use callback to handle transaction #5455

Merged

Conversation

sunfuze
Copy link
Contributor

@sunfuze sunfuze commented Jun 24, 2022

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Make transaction have before and after hooks, so plugin can hack before
or after transaction.

User Case Description

We hava a gorm plugin to handle database sharding. We save SaaS tenant info into context, then plugin can get the tenant in before hooks and determine which database shard to select. For now, Transaction api is not invoked through callbacks, we have to wrap gorm.ConnPool as gorm.ConnPoolBeginner to select database.

- make transaction have before and after hooks, so plugin can have hack before
or after transaction
@huacnlee huacnlee merged commit 5c4016d into go-gorm:master Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants