Closed jiekun closed 2 years ago
@jinzhu @huacnlee PTAL.
In case I am not fixing this bug in the correct way, I would like to hear more from ya before finishing the PR. Tagged as [WIP]
for now.
TxCommitter
Hi. I'm closing this PR due to the lack of time to review and push it further. The issue is still present as described above.
What did this pull request do?
Currently, sharding lib cannot start transaction correctly.
(pool *ConnPool) BeginTx()
method,pool.ConnPool
is actually*sql.DB
and not match thegorm.ConnPoolBeginner
interface. Sopool, nil
is returned and transaction is not started.BeginTx
/Commit
/Rollback
return nil when interface not match. When executing write operation, transaction is automatically called:BeginTransaction
. If no error returned, it will consider the transaction started by GORM and try to commit it inCommitOrRollbackTransaction
.In this PR, problems above are fixed by:
BeginTx
so theBeginTx
could be called.gorm. ErrInvalidTransaction
instead of nil, which could be handled intransaction.go
User Case Description
N/A