在db resolver中定义了多数据库的链接配置,但在使用事物的时候无法使用db resolver中配置的数据库,只能用默认的数据库进行事物操作

The document you expected this should be explained

有没有办法能在事务开启的时候选择数据库链接呢?

Comment From: ghost

@soooldier https://gorm.io/zh_CN/docs/dbresolver.html#%E6%89%8B%E5%8A%A8%E5%88%87%E6%8D%A2%E8%BF%9E%E6%8E%A5

Comment From: li-jin-gou

这里应该没办法直接支持,想到的一个办法是:

tx.Statement.ConnPool, err = beginner.BeginTx(tx.Statement.Context, opt)
if err !=nil{
     return 
}

直接对 ConnPool 赋值一个开启事务的 Conn .