feat: define xorm.FromDialectAndDB #1812

Merged
lunny merged 2 commits from jumpeiMano/xorm:add-from-db into master 2020-10-20 03:11:12 +00:00
Contributor

Hi! I use your greate library, xorm.

I'd like to use xorm.Engine with my own *sql.DB instances. Because I also want to use SessionResetter interface, so I want to call sql.OpenDB to create my own *sql.DB instance before creating *xorm.Engine instance.

So I define FromDialectAndDB function in package xorm.

Thanks!

Hi! I use your greate library, `xorm`. I'd like to use xorm.Engine with my own *sql.DB instances. Because I also want to use [SessionResetter](https://github.com/golang/go/blob/9499a2e108/src/database/sql/driver/driver.go#L291) interface, so I want to call [sql.OpenDB](https://github.com/golang/go/blob/9499a2e108/src/database/sql/sql.go#L730) to create my own *sql.DB instance before creating *xorm.Engine instance. So I define `FromDialectAndDB` function in package `xorm`. Thanks!
jumpeiMano added 1 commit 2020-10-19 05:53:12 +00:00
lunny reviewed 2020-10-20 02:38:28 +00:00
Dismissed
engine.go Outdated
@ -104,0 +109,4 @@
// If you do not want to use your own dialect or db, please use NewEngine.
// For creating dialect, you can call dialects.OpenDialect. And, for creating db,
// you can call core.Open or core.FromDB.
func FromDialectAndDB(driverName, dataSourceName string, dialect dialects.Dialect, db *core.DB) (*Engine, error) {
Owner

How about rename it NewEngineWith.... to keep consistent with NewEngineWithParams.

How about rename it `NewEngineWith....` to keep consistent with `NewEngineWithParams`.
Author
Contributor

@lunny Thanks for your reviewng. I fixed it!
fa7f45555f

@lunny Thanks for your reviewng. I fixed it! https://gitea.com/xorm/xorm/commit/fa7f45555f1232c2c62e2701be1680b8e644764d
lunny marked this conversation as resolved
lunny added the
kind
feature
label 2020-10-20 02:38:37 +00:00
jumpeiMano added 1 commit 2020-10-20 03:03:39 +00:00
lunny approved these changes 2020-10-20 03:10:58 +00:00
Dismissed
lunny merged commit 17f28a1314 into master 2020-10-20 03:11:04 +00:00
Sign in to join this conversation.
No description provided.