(fix) remove ad-hoc case for YDB

- add method `GetDB()` for `core.Tx`, that method is used to obtain
  internal db.
This commit is contained in:
datbeohbbh 2023-09-27 16:01:22 +07:00
parent a3c13ae160
commit bb4f917e64
3 changed files with 9 additions and 3 deletions

View File

@ -236,3 +236,7 @@ func (tx *Tx) QueryRowStructContext(ctx context.Context, query string, st interf
func (tx *Tx) QueryRowStruct(query string, st interface{}) *Row {
return tx.QueryRowStructContext(context.Background(), query, st)
}
func (tx *Tx) GetDB() *DB {
return tx.db
}

View File

@ -397,6 +397,11 @@ func (db *ydb) getDB(queryer interface{}) *core.DB {
if internalDB, ok := queryer.(*core.DB); ok {
return internalDB
}
if txGetDB, ok := queryer.(interface {
GetDB() *core.DB
}); ok {
return txGetDB.GetDB()
}
return nil
}

View File

@ -187,9 +187,6 @@ func (session *Session) Tx() *core.Tx {
}
func (session *Session) getQueryer() core.Queryer {
if session.engine.dialect.URI().DBType == schemas.YDB {
return session.db()
}
if session.tx != nil {
return session.tx
}