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

master
chen quan 1 year ago committed by GitHub
parent 31b9ba19a2
commit b71453985c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -399,3 +399,11 @@ func (s statement) QueryRowsPartialCtx(ctx context.Context, v any, args ...any)
return unmarshalRows(v, rows, false) return unmarshalRows(v, rows, false)
}, s.query, args...) }, 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
}
}

Loading…
Cancel
Save