Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Feb 4, 2025
1 parent 23190ab commit 2833fab
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,19 @@ func (d *sqlDriver) attach(c *xsql.Connector, parent *Driver) {
}

func (d *sqlDriver) detach(c *xsql.Connector) {
var countConnectorsPerDriver int
parent, _ := d.connectors.Extract(c)
if d.connectors.Len() == 0 && parent != nil {
_ = parent.Close(context.Background())
if parent != nil {
d.connectors.Range(func(key *xsql.Connector, value *Driver) bool {
if value == parent {
countConnectorsPerDriver++
}

return true
})
if countConnectorsPerDriver == 0 {
_ = parent.Close(context.Background())
}
}
}

Expand Down

0 comments on commit 2833fab

Please sign in to comment.