fix: mysql WithAcceptable bug (#3986)

This commit is contained in:
MarkJoyMa
2024-03-08 12:23:41 +08:00
committed by GitHub
parent 2207477b60
commit c7dacb0146
4 changed files with 50 additions and 4 deletions

View File

@@ -315,6 +315,13 @@ func (db *commonSqlConn) queryRows(ctx context.Context, scanner func(*sql.Rows)
// acceptable is the func to check if the error can be accepted.
func WithAcceptable(acceptable func(err error) bool) SqlOption {
return func(conn *commonSqlConn) {
conn.accept = acceptable
if conn.accept == nil {
conn.accept = acceptable
} else {
pre := conn.accept
conn.accept = func(err error) bool {
return pre(err) || acceptable(err)
}
}
}
}