From 6aba5f74fc8490c2e70f11e9ac02dfbc1e4483c6 Mon Sep 17 00:00:00 2001 From: yedf2 <43027375+yedf2@users.noreply.github.com> Date: Wed, 3 Nov 2021 20:56:02 +0800 Subject: [PATCH] feat: add NewSessionFromTx to interact with other orm (#1202) Co-authored-by: yedongfu --- core/stores/sqlx/tx.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/stores/sqlx/tx.go b/core/stores/sqlx/tx.go index 0ae35ff9..cbb5c4db 100644 --- a/core/stores/sqlx/tx.go +++ b/core/stores/sqlx/tx.go @@ -19,6 +19,12 @@ type ( } ) +// 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 { + return txSession{Tx: tx} +} + func (t txSession) Exec(q string, args ...interface{}) (sql.Result, error) { return exec(t.Tx, q, args...) }