feat(sqlx): support for custom Acceptable function (#3405)

This commit is contained in:
chen quan
2023-07-10 09:16:45 +08:00
committed by GitHub
parent 31b9ba19a2
commit b71453985c
2 changed files with 9 additions and 3 deletions

View File

@@ -32,7 +32,5 @@ func mysqlAcceptable(err error) bool {
}
func withMysqlAcceptable() SqlOption {
return func(conn *commonSqlConn) {
conn.accept = mysqlAcceptable
}
return WithAcceptable(mysqlAcceptable)
}

View File

@@ -399,3 +399,11 @@ func (s statement) QueryRowsPartialCtx(ctx context.Context, v any, args ...any)
return unmarshalRows(v, rows, false)
}, s.query, args...)
}
// WithAcceptable returns a SqlOption that setting the acceptable function.
// 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
}
}