diff --git a/core/stores/sqlx/mysql.go b/core/stores/sqlx/mysql.go index 9f474f55..6f0f731d 100644 --- a/core/stores/sqlx/mysql.go +++ b/core/stores/sqlx/mysql.go @@ -32,7 +32,5 @@ func mysqlAcceptable(err error) bool { } func withMysqlAcceptable() SqlOption { - return func(conn *commonSqlConn) { - conn.accept = mysqlAcceptable - } + return WithAcceptable(mysqlAcceptable) } diff --git a/core/stores/sqlx/sqlconn.go b/core/stores/sqlx/sqlconn.go index e1297251..fdb9d2be 100644 --- a/core/stores/sqlx/sqlconn.go +++ b/core/stores/sqlx/sqlconn.go @@ -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 + } +}