mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-25 14:36:20 -06:00
[chore]: Bump github.com/uptrace/bun/extra/bunotel from 1.2.9 to 1.2.10
Bumps [github.com/uptrace/bun/extra/bunotel](https://github.com/uptrace/bun) from 1.2.9 to 1.2.10. - [Release notes](https://github.com/uptrace/bun/releases) - [Changelog](https://github.com/uptrace/bun/blob/master/CHANGELOG.md) - [Commits](https://github.com/uptrace/bun/compare/v1.2.9...v1.2.10) --- updated-dependencies: - dependency-name: github.com/uptrace/bun/extra/bunotel dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
8488ac9286
commit
78e03263ea
31 changed files with 417 additions and 204 deletions
24
vendor/github.com/uptrace/bun/util.go
generated
vendored
24
vendor/github.com/uptrace/bun/util.go
generated
vendored
|
|
@ -1,6 +1,7 @@
|
|||
package bun
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
|
@ -86,3 +87,26 @@ func appendComment(b []byte, name string) []byte {
|
|||
name = strings.ReplaceAll(name, `*/`, `*\/`)
|
||||
return append(b, fmt.Sprintf("/* %s */ ", name)...)
|
||||
}
|
||||
|
||||
// queryCommentCtxKey is a context key for setting a query comment on a context instead of calling the Comment("...") API directly
|
||||
type queryCommentCtxKey struct{}
|
||||
|
||||
// WithComment returns a context that includes a comment that may be included in a query for debugging
|
||||
//
|
||||
// If a context with an attached query is used, a comment set by the Comment("...") API will be overwritten.
|
||||
func WithComment(ctx context.Context, comment string) context.Context {
|
||||
return context.WithValue(ctx, queryCommentCtxKey{}, comment)
|
||||
}
|
||||
|
||||
// commenter describes the Comment interface implemented by all of the query types
|
||||
type commenter[T any] interface {
|
||||
Comment(string) T
|
||||
}
|
||||
|
||||
// setCommentFromContext sets the comment on the given query from the supplied context if one is set using the Comment(...) method.
|
||||
func setCommentFromContext[T any](ctx context.Context, q commenter[T]) {
|
||||
s, _ := ctx.Value(queryCommentCtxKey{}).(string)
|
||||
if s != "" {
|
||||
q.Comment(s)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue