(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:
parent
a3c13ae160
commit
bb4f917e64
|
@ -236,3 +236,7 @@ func (tx *Tx) QueryRowStructContext(ctx context.Context, query string, st interf
|
||||||
func (tx *Tx) QueryRowStruct(query string, st interface{}) *Row {
|
func (tx *Tx) QueryRowStruct(query string, st interface{}) *Row {
|
||||||
return tx.QueryRowStructContext(context.Background(), query, st)
|
return tx.QueryRowStructContext(context.Background(), query, st)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tx *Tx) GetDB() *DB {
|
||||||
|
return tx.db
|
||||||
|
}
|
||||||
|
|
|
@ -397,6 +397,11 @@ func (db *ydb) getDB(queryer interface{}) *core.DB {
|
||||||
if internalDB, ok := queryer.(*core.DB); ok {
|
if internalDB, ok := queryer.(*core.DB); ok {
|
||||||
return internalDB
|
return internalDB
|
||||||
}
|
}
|
||||||
|
if txGetDB, ok := queryer.(interface {
|
||||||
|
GetDB() *core.DB
|
||||||
|
}); ok {
|
||||||
|
return txGetDB.GetDB()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,9 +187,6 @@ func (session *Session) Tx() *core.Tx {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) getQueryer() core.Queryer {
|
func (session *Session) getQueryer() core.Queryer {
|
||||||
if session.engine.dialect.URI().DBType == schemas.YDB {
|
|
||||||
return session.db()
|
|
||||||
}
|
|
||||||
if session.tx != nil {
|
if session.tx != nil {
|
||||||
return session.tx
|
return session.tx
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue