expose sql.DB to let orm operate on it (#1015)

* expose sql.DB to let orm operate on it

* add missing RawDB methods

* add NewSqlConnFromDB for cooperate with dtm
This commit is contained in:
Kevin Wan
2021-09-09 11:40:28 +08:00
committed by GitHub
parent 56807aabf6
commit f6d9e19ecb
6 changed files with 61 additions and 10 deletions

View File

@@ -13,6 +13,7 @@ type (
MockConn struct {
db *sql.DB
}
statement struct {
stmt *sql.Stmt
}
@@ -62,6 +63,11 @@ func (conn *MockConn) QueryRowsPartial(v interface{}, q string, args ...interfac
}, q, args...)
}
// RawDB returns the underlying sql.DB.
func (conn *MockConn) RawDB() (*sql.DB, error) {
return conn.db, nil
}
// Transact is the implemention of sqlx.SqlConn, nothing to do
func (conn *MockConn) Transact(func(session sqlx.Session) error) error {
return nil