feat: support using session to execute statements in transaction (#3252)
This commit is contained in:
@@ -15,11 +15,27 @@ type (
|
||||
Rollback() error
|
||||
}
|
||||
|
||||
txConn struct {
|
||||
Session
|
||||
}
|
||||
|
||||
txSession struct {
|
||||
*sql.Tx
|
||||
}
|
||||
)
|
||||
|
||||
func (s txConn) RawDB() (*sql.DB, error) {
|
||||
return nil, errNoRawDBFromTx
|
||||
}
|
||||
|
||||
func (s txConn) Transact(_ func(Session) error) error {
|
||||
return errCantNestTx
|
||||
}
|
||||
|
||||
func (s txConn) TransactCtx(_ context.Context, _ func(context.Context, Session) error) error {
|
||||
return errCantNestTx
|
||||
}
|
||||
|
||||
// NewSessionFromTx returns a Session with the given sql.Tx.
|
||||
// Use it with caution, it's provided for other ORM to interact with.
|
||||
func NewSessionFromTx(tx *sql.Tx) Session {
|
||||
|
||||
Reference in New Issue
Block a user