mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-16 03:03:02 -06:00
bumps our uptrace/bun dependencies to v1.2.10 (#3865)
This commit is contained in:
parent
ddd9210614
commit
67a2b3650c
37 changed files with 518 additions and 225 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