summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/uptrace/bun/util.go')
-rw-r--r--vendor/github.com/uptrace/bun/util.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/vendor/github.com/uptrace/bun/util.go b/vendor/github.com/uptrace/bun/util.go
index 09ffbb996..97ed9228a 100644
--- a/vendor/github.com/uptrace/bun/util.go
+++ b/vendor/github.com/uptrace/bun/util.go
@@ -1,6 +1,10 @@
package bun
-import "reflect"
+import (
+ "fmt"
+ "reflect"
+ "strings"
+)
func indirect(v reflect.Value) reflect.Value {
switch v.Kind() {
@@ -66,3 +70,19 @@ func sliceElemType(v reflect.Value) reflect.Type {
}
return indirectType(elemType)
}
+
+// appendComment adds comment in the header of the query into buffer
+func appendComment(b []byte, name string) []byte {
+ if name == "" {
+ return b
+ }
+ name = strings.Map(func(r rune) rune {
+ if r == '\x00' {
+ return -1
+ }
+ return r
+ }, name)
+ name = strings.ReplaceAll(name, `/*`, `/\*`)
+ name = strings.ReplaceAll(name, `*/`, `*\/`)
+ return append(b, fmt.Sprintf("/* %s */ ", name)...)
+}