소스 검색

feat: add NewSessionFromTx to interact with other orm (#1202)

Co-authored-by: yedongfu <dongfuye@163.com>
yedf2 3 년 전
부모
커밋
6aba5f74fc
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      core/stores/sqlx/tx.go

+ 6 - 0
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) {
 func (t txSession) Exec(q string, args ...interface{}) (sql.Result, error) {
 	return exec(t.Tx, q, args...)
 	return exec(t.Tx, q, args...)
 }
 }