Skip to content

Commit

Permalink
feat: export manual db connection open and close (#149)
Browse files Browse the repository at this point in the history
Signed-off-by: abingcbc <abingcbc626@gmail.com>
  • Loading branch information
Abingcbc authored Feb 10, 2022
1 parent a4afbc9 commit 7b3bc27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func NewAdapter(driverName string, dataSourceName string, params ...interface{})
}

// Open the DB, create it if not existed.
err := a.open()
err := a.Open()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -304,7 +304,7 @@ func (a *Adapter) createDatabase() error {
return nil
}

func (a *Adapter) open() error {
func (a *Adapter) Open() error {
var err error
var db *gorm.DB

Expand Down Expand Up @@ -338,8 +338,8 @@ func (a *Adapter) AddLogger(l logger.Interface) {
a.db = a.db.Session(&gorm.Session{Logger: l, Context: a.db.Statement.Context})
}

func (a *Adapter) close() error {
a.db = nil
func (a *Adapter) Close() error {
finalizer(a)
return nil
}

Expand Down

0 comments on commit 7b3bc27

Please sign in to comment.