mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-09 22:42:55 +08:00
🐛 fix(query-editor): 修复 Oracle 事务提交回滚失败
- 分离 Oracle 托管事务与单次查询执行上下文 - 避免查询结束后取消 BeginTx 上下文导致事务提前回滚 - 补充 sql.ErrTxDone 回归测试覆盖 Oracle 提交路径
This commit is contained in:
@@ -2,6 +2,7 @@ package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
@@ -227,22 +228,30 @@ type fakeTransactionalDB struct {
|
||||
func (f *fakeTransactionalDB) OpenTransactionExecer(ctx context.Context) (db.TransactionExecer, error) {
|
||||
f.txSession = &fakeTransactionSession{
|
||||
fakeBatchWriteSession: fakeBatchWriteSession{parent: &f.fakeBatchWriteDB},
|
||||
beginCtx: ctx,
|
||||
}
|
||||
return f.txSession, nil
|
||||
}
|
||||
|
||||
type fakeTransactionSession struct {
|
||||
fakeBatchWriteSession
|
||||
beginCtx context.Context
|
||||
commitCalls int
|
||||
rollbackCalls int
|
||||
}
|
||||
|
||||
func (s *fakeTransactionSession) Commit() error {
|
||||
if s.beginCtx != nil && s.beginCtx.Err() != nil {
|
||||
return sql.ErrTxDone
|
||||
}
|
||||
s.commitCalls++
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *fakeTransactionSession) Rollback() error {
|
||||
if s.beginCtx != nil && s.beginCtx.Err() != nil {
|
||||
return sql.ErrTxDone
|
||||
}
|
||||
s.rollbackCalls++
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user