Skip to content

Commit 14d3ded

Browse files
committed
fix
1 parent 52aff4c commit 14d3ded

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

sql.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,19 @@ func (d *sqlDriver) attach(c *xsql.Connector, parent *Driver) {
6767
}
6868

6969
func (d *sqlDriver) detach(c *xsql.Connector) {
70+
var countConnectorsPerDriver int
7071
parent, _ := d.connectors.Extract(c)
71-
if d.connectors.Len() == 0 && parent != nil {
72-
_ = parent.Close(context.Background())
72+
if parent != nil {
73+
d.connectors.Range(func(key *xsql.Connector, value *Driver) bool {
74+
if value == parent {
75+
countConnectorsPerDriver++
76+
}
77+
78+
return true
79+
})
80+
if countConnectorsPerDriver == 0 {
81+
_ = parent.Close(context.Background())
82+
}
7383
}
7484
}
7585

0 commit comments

Comments
 (0)