diff options
Diffstat (limited to 'vendor/github.com/uptrace/bun/internal')
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/flag.go | 16 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/hex.go | 43 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/logger.go | 54 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/map_key.go | 67 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/ordered/map.go | 125 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/parser/parser.go | 169 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/safe.go | 11 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/tagparser/parser.go | 184 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/time.go | 61 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/underscore.go | 67 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/unsafe.go | 22 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/util.go | 87 |
12 files changed, 0 insertions, 906 deletions
diff --git a/vendor/github.com/uptrace/bun/internal/flag.go b/vendor/github.com/uptrace/bun/internal/flag.go deleted file mode 100644 index 22d2db291..000000000 --- a/vendor/github.com/uptrace/bun/internal/flag.go +++ /dev/null @@ -1,16 +0,0 @@ -package internal - -type Flag uint64 - -func (flag Flag) Has(other Flag) bool { - return flag&other != 0 -} - -func (flag Flag) Set(other Flag) Flag { - return flag | other -} - -func (flag Flag) Remove(other Flag) Flag { - flag &= ^other - return flag -} diff --git a/vendor/github.com/uptrace/bun/internal/hex.go b/vendor/github.com/uptrace/bun/internal/hex.go deleted file mode 100644 index 6fae2bb78..000000000 --- a/vendor/github.com/uptrace/bun/internal/hex.go +++ /dev/null @@ -1,43 +0,0 @@ -package internal - -import ( - fasthex "github.com/tmthrgd/go-hex" -) - -type HexEncoder struct { - b []byte - written bool -} - -func NewHexEncoder(b []byte) *HexEncoder { - return &HexEncoder{ - b: b, - } -} - -func (enc *HexEncoder) Bytes() []byte { - return enc.b -} - -func (enc *HexEncoder) Write(b []byte) (int, error) { - if !enc.written { - enc.b = append(enc.b, '\'') - enc.b = append(enc.b, `\x`...) - enc.written = true - } - - i := len(enc.b) - enc.b = append(enc.b, make([]byte, fasthex.EncodedLen(len(b)))...) - fasthex.Encode(enc.b[i:], b) - - return len(b), nil -} - -func (enc *HexEncoder) Close() error { - if enc.written { - enc.b = append(enc.b, '\'') - } else { - enc.b = append(enc.b, "NULL"...) - } - return nil -} diff --git a/vendor/github.com/uptrace/bun/internal/logger.go b/vendor/github.com/uptrace/bun/internal/logger.go deleted file mode 100644 index 9233dfcff..000000000 --- a/vendor/github.com/uptrace/bun/internal/logger.go +++ /dev/null @@ -1,54 +0,0 @@ -package internal - -import ( - "fmt" - "log" - "os" -) - -type Logging interface { - Printf(format string, v ...interface{}) -} - -var defaultLogger = log.New(os.Stderr, "", log.LstdFlags) - -var Logger Logging = &logger{ - log: defaultLogger, -} - -var Warn = &wrapper{ - prefix: "WARN: bun: ", - logger: Logger, -} - -var Deprecated = &wrapper{ - prefix: "DEPRECATED: bun: ", - logger: Logger, -} - -type logger struct { - log *log.Logger -} - -func (l *logger) Printf(format string, v ...interface{}) { - _ = l.log.Output(2, fmt.Sprintf(format, v...)) -} - -type wrapper struct { - prefix string - logger Logging -} - -func (w *wrapper) Printf(format string, v ...interface{}) { - w.logger.Printf(w.prefix+format, v...) -} - -func SetLogger(newLogger Logging) { - if newLogger == nil { - Logger = &logger{log: defaultLogger} - } else { - Logger = newLogger - } - Warn.logger = Logger - Deprecated.logger = Logger -} diff --git a/vendor/github.com/uptrace/bun/internal/map_key.go b/vendor/github.com/uptrace/bun/internal/map_key.go deleted file mode 100644 index d7e4de2b9..000000000 --- a/vendor/github.com/uptrace/bun/internal/map_key.go +++ /dev/null @@ -1,67 +0,0 @@ -package internal - -import "reflect" - -var ifaceType = reflect.TypeFor[interface{}]() - -type MapKey struct { - iface interface{} -} - -func NewMapKey(is []interface{}) MapKey { - return MapKey{ - iface: newMapKey(is), - } -} - -func newMapKey(is []interface{}) interface{} { - switch len(is) { - case 1: - ptr := new([1]interface{}) - copy((*ptr)[:], is) - return *ptr - case 2: - ptr := new([2]interface{}) - copy((*ptr)[:], is) - return *ptr - case 3: - ptr := new([3]interface{}) - copy((*ptr)[:], is) - return *ptr - case 4: - ptr := new([4]interface{}) - copy((*ptr)[:], is) - return *ptr - case 5: - ptr := new([5]interface{}) - copy((*ptr)[:], is) - return *ptr - case 6: - ptr := new([6]interface{}) - copy((*ptr)[:], is) - return *ptr - case 7: - ptr := new([7]interface{}) - copy((*ptr)[:], is) - return *ptr - case 8: - ptr := new([8]interface{}) - copy((*ptr)[:], is) - return *ptr - case 9: - ptr := new([9]interface{}) - copy((*ptr)[:], is) - return *ptr - case 10: - ptr := new([10]interface{}) - copy((*ptr)[:], is) - return *ptr - default: - } - - at := reflect.New(reflect.ArrayOf(len(is), ifaceType)).Elem() - for i, v := range is { - *(at.Index(i).Addr().Interface().(*interface{})) = v - } - return at.Interface() -} diff --git a/vendor/github.com/uptrace/bun/internal/ordered/map.go b/vendor/github.com/uptrace/bun/internal/ordered/map.go deleted file mode 100644 index d5e4f7d9d..000000000 --- a/vendor/github.com/uptrace/bun/internal/ordered/map.go +++ /dev/null @@ -1,125 +0,0 @@ -package ordered - -// Pair represents a key-value pair in the ordered map. -type Pair[K comparable, V any] struct { - Key K - Value V - - next, prev *Pair[K, V] // Pointers to the next and previous pairs in the linked list. -} - -// Map represents an ordered map. -type Map[K comparable, V any] struct { - root *Pair[K, V] // Sentinel node for the circular doubly linked list. - zero V // Zero value for the value type. - - pairs map[K]*Pair[K, V] // Map from keys to pairs. -} - -// NewMap creates a new ordered map with optional initial data. -func NewMap[K comparable, V any](initialData ...Pair[K, V]) *Map[K, V] { - m := &Map[K, V]{} - m.Clear() - for _, pair := range initialData { - m.Store(pair.Key, pair.Value) - } - return m -} - -// Clear removes all pairs from the map. -func (m *Map[K, V]) Clear() { - if m.root != nil { - m.root.next, m.root.prev = nil, nil // avoid memory leaks - } - for _, pair := range m.pairs { - pair.next, pair.prev = nil, nil // avoid memory leaks - } - m.root = &Pair[K, V]{} - m.root.next, m.root.prev = m.root, m.root - m.pairs = make(map[K]*Pair[K, V]) -} - -// Len returns the number of pairs in the map. -func (m *Map[K, V]) Len() int { - return len(m.pairs) -} - -// Load returns the value associated with the key, and a boolean indicating if the key was found. -func (m *Map[K, V]) Load(key K) (V, bool) { - if pair, present := m.pairs[key]; present { - return pair.Value, true - } - return m.zero, false -} - -// Value returns the value associated with the key, or the zero value if the key is not found. -func (m *Map[K, V]) Value(key K) V { - if pair, present := m.pairs[key]; present { - return pair.Value - } - return m.zero -} - -// Store adds or updates a key-value pair in the map. -func (m *Map[K, V]) Store(key K, value V) { - if pair, present := m.pairs[key]; present { - pair.Value = value - return - } - - pair := &Pair[K, V]{Key: key, Value: value} - pair.prev = m.root.prev - m.root.prev.next = pair - m.root.prev = pair - pair.next = m.root - m.pairs[key] = pair -} - -// Delete removes a key-value pair from the map. -func (m *Map[K, V]) Delete(key K) { - if pair, present := m.pairs[key]; present { - pair.prev.next = pair.next - pair.next.prev = pair.prev - pair.next, pair.prev = nil, nil // avoid memory leaks - delete(m.pairs, key) - } -} - -// Range calls the given function for each key-value pair in the map in order. -func (m *Map[K, V]) Range(yield func(key K, value V) bool) { - for pair := m.root.next; pair != m.root; pair = pair.next { - if !yield(pair.Key, pair.Value) { - break - } - } -} - -// Keys returns a slice of all keys in the map in order. -func (m *Map[K, V]) Keys() []K { - keys := make([]K, 0, len(m.pairs)) - m.Range(func(key K, _ V) bool { - keys = append(keys, key) - return true - }) - return keys -} - -// Values returns a slice of all values in the map in order. -func (m *Map[K, V]) Values() []V { - values := make([]V, 0, len(m.pairs)) - m.Range(func(_ K, value V) bool { - values = append(values, value) - return true - }) - return values -} - -// Pairs returns a slice of all key-value pairs in the map in order. -func (m *Map[K, V]) Pairs() []Pair[K, V] { - pairs := make([]Pair[K, V], 0, len(m.pairs)) - m.Range(func(key K, value V) bool { - pairs = append(pairs, Pair[K, V]{Key: key, Value: value}) - return true - }) - return pairs -} diff --git a/vendor/github.com/uptrace/bun/internal/parser/parser.go b/vendor/github.com/uptrace/bun/internal/parser/parser.go deleted file mode 100644 index 1f2704478..000000000 --- a/vendor/github.com/uptrace/bun/internal/parser/parser.go +++ /dev/null @@ -1,169 +0,0 @@ -package parser - -import ( - "bytes" - "fmt" - "io" - "strconv" - - "github.com/uptrace/bun/internal" -) - -type Parser struct { - b []byte - i int -} - -func New(b []byte) *Parser { - return &Parser{ - b: b, - } -} - -func NewString(s string) *Parser { - return New(internal.Bytes(s)) -} - -func (p *Parser) Reset(b []byte) { - p.b = b - p.i = 0 -} - -func (p *Parser) Valid() bool { - return p.i < len(p.b) -} - -func (p *Parser) Remaining() []byte { - return p.b[p.i:] -} - -func (p *Parser) ReadByte() (byte, error) { - if p.Valid() { - ch := p.b[p.i] - p.Advance() - return ch, nil - } - return 0, io.ErrUnexpectedEOF -} - -func (p *Parser) Read() byte { - if p.Valid() { - ch := p.b[p.i] - p.Advance() - return ch - } - return 0 -} - -func (p *Parser) Unread() { - if p.i > 0 { - p.i-- - } -} - -func (p *Parser) Peek() byte { - if p.Valid() { - return p.b[p.i] - } - return 0 -} - -func (p *Parser) Advance() { - p.i++ -} - -func (p *Parser) Skip(skip byte) error { - ch := p.Peek() - if ch == skip { - p.Advance() - return nil - } - return fmt.Errorf("got %q, wanted %q", ch, skip) -} - -func (p *Parser) SkipPrefix(skip []byte) error { - if !bytes.HasPrefix(p.b[p.i:], skip) { - return fmt.Errorf("got %q, wanted prefix %q", p.b, skip) - } - p.i += len(skip) - return nil -} - -func (p *Parser) CutPrefix(skip []byte) bool { - if !bytes.HasPrefix(p.b[p.i:], skip) { - return false - } - p.i += len(skip) - return true -} - -func (p *Parser) ReadSep(sep byte) ([]byte, bool) { - ind := bytes.IndexByte(p.b[p.i:], sep) - if ind == -1 { - b := p.b[p.i:] - p.i = len(p.b) - return b, false - } - - b := p.b[p.i : p.i+ind] - p.i += ind + 1 - return b, true -} - -func (p *Parser) ReadIdentifier() (string, bool) { - if p.i < len(p.b) && p.b[p.i] == '(' { - s := p.i + 1 - if ind := bytes.IndexByte(p.b[s:], ')'); ind != -1 { - b := p.b[s : s+ind] - p.i = s + ind + 1 - return internal.String(b), false - } - } - - ind := len(p.b) - p.i - var alpha bool - for i, c := range p.b[p.i:] { - if isNum(c) { - continue - } - if isAlpha(c) || (i > 0 && alpha && c == '_') { - alpha = true - continue - } - ind = i - break - } - if ind == 0 { - return "", false - } - b := p.b[p.i : p.i+ind] - p.i += ind - return internal.String(b), !alpha -} - -func (p *Parser) ReadNumber() int { - ind := len(p.b) - p.i - for i, c := range p.b[p.i:] { - if !isNum(c) { - ind = i - break - } - } - if ind == 0 { - return 0 - } - n, err := strconv.Atoi(string(p.b[p.i : p.i+ind])) - if err != nil { - panic(err) - } - p.i += ind - return n -} - -func isNum(c byte) bool { - return c >= '0' && c <= '9' -} - -func isAlpha(c byte) bool { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') -} diff --git a/vendor/github.com/uptrace/bun/internal/safe.go b/vendor/github.com/uptrace/bun/internal/safe.go deleted file mode 100644 index 862ff0eb3..000000000 --- a/vendor/github.com/uptrace/bun/internal/safe.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build appengine - -package internal - -func String(b []byte) string { - return string(b) -} - -func Bytes(s string) []byte { - return []byte(s) -} diff --git a/vendor/github.com/uptrace/bun/internal/tagparser/parser.go b/vendor/github.com/uptrace/bun/internal/tagparser/parser.go deleted file mode 100644 index a3905853d..000000000 --- a/vendor/github.com/uptrace/bun/internal/tagparser/parser.go +++ /dev/null @@ -1,184 +0,0 @@ -package tagparser - -import ( - "strings" -) - -type Tag struct { - Name string - Options map[string][]string -} - -func (t Tag) IsZero() bool { - return t.Name == "" && t.Options == nil -} - -func (t Tag) HasOption(name string) bool { - _, ok := t.Options[name] - return ok -} - -func (t Tag) Option(name string) (string, bool) { - if vs, ok := t.Options[name]; ok { - return vs[len(vs)-1], true - } - return "", false -} - -func Parse(s string) Tag { - if s == "" { - return Tag{} - } - p := parser{ - s: s, - } - p.parse() - return p.tag -} - -type parser struct { - s string - i int - - tag Tag - seenName bool // for empty names -} - -func (p *parser) setName(name string) { - if p.seenName { - p.addOption(name, "") - } else { - p.seenName = true - p.tag.Name = name - } -} - -func (p *parser) addOption(key, value string) { - p.seenName = true - if key == "" { - return - } - if p.tag.Options == nil { - p.tag.Options = make(map[string][]string) - } - if vs, ok := p.tag.Options[key]; ok { - p.tag.Options[key] = append(vs, value) - } else { - p.tag.Options[key] = []string{value} - } -} - -func (p *parser) parse() { - for p.valid() { - p.parseKeyValue() - if p.peek() == ',' { - p.i++ - } - } -} - -func (p *parser) parseKeyValue() { - start := p.i - - for p.valid() { - switch c := p.read(); c { - case ',': - key := p.s[start : p.i-1] - p.setName(key) - return - case ':': - key := p.s[start : p.i-1] - value := p.parseValue() - p.addOption(key, value) - return - case '"': - key := p.parseQuotedValue() - p.setName(key) - return - } - } - - key := p.s[start:p.i] - p.setName(key) -} - -func (p *parser) parseValue() string { - start := p.i - - for p.valid() { - switch c := p.read(); c { - case '"': - return p.parseQuotedValue() - case ',': - return p.s[start : p.i-1] - case '(': - p.skipPairs('(', ')') - } - } - - if p.i == start { - return "" - } - return p.s[start:p.i] -} - -func (p *parser) parseQuotedValue() string { - if i := strings.IndexByte(p.s[p.i:], '"'); i >= 0 && p.s[p.i+i-1] != '\\' { - s := p.s[p.i : p.i+i] - p.i += i + 1 - return s - } - - b := make([]byte, 0, 16) - - for p.valid() { - switch c := p.read(); c { - case '\\': - b = append(b, p.read()) - case '"': - return string(b) - default: - b = append(b, c) - } - } - - return "" -} - -func (p *parser) skipPairs(start, end byte) { - var lvl int - for p.valid() { - switch c := p.read(); c { - case '"': - _ = p.parseQuotedValue() - case start: - lvl++ - case end: - if lvl == 0 { - return - } - lvl-- - } - } -} - -func (p *parser) valid() bool { - return p.i < len(p.s) -} - -func (p *parser) read() byte { - if !p.valid() { - return 0 - } - c := p.s[p.i] - p.i++ - return c -} - -func (p *parser) peek() byte { - if !p.valid() { - return 0 - } - c := p.s[p.i] - return c -} diff --git a/vendor/github.com/uptrace/bun/internal/time.go b/vendor/github.com/uptrace/bun/internal/time.go deleted file mode 100644 index 2cb69b46a..000000000 --- a/vendor/github.com/uptrace/bun/internal/time.go +++ /dev/null @@ -1,61 +0,0 @@ -package internal - -import ( - "fmt" - "time" -) - -const ( - dateFormat = "2006-01-02" - timeFormat = "15:04:05.999999999" - timetzFormat1 = "15:04:05.999999999-07:00:00" - timetzFormat2 = "15:04:05.999999999-07:00" - timetzFormat3 = "15:04:05.999999999-07" - timestampFormat = "2006-01-02 15:04:05.999999999" - timestamptzFormat1 = "2006-01-02 15:04:05.999999999-07:00:00" - timestamptzFormat2 = "2006-01-02 15:04:05.999999999-07:00" - timestamptzFormat3 = "2006-01-02 15:04:05.999999999-07" -) - -func ParseTime(s string) (time.Time, error) { - l := len(s) - - if l >= len("2006-01-02 15:04:05") { - switch s[10] { - case ' ': - if c := s[l-6]; c == '+' || c == '-' { - return time.Parse(timestamptzFormat2, s) - } - if c := s[l-3]; c == '+' || c == '-' { - return time.Parse(timestamptzFormat3, s) - } - if c := s[l-9]; c == '+' || c == '-' { - return time.Parse(timestamptzFormat1, s) - } - return time.ParseInLocation(timestampFormat, s, time.UTC) - case 'T': - return time.Parse(time.RFC3339Nano, s) - } - } - - if l >= len("15:04:05-07") { - if c := s[l-6]; c == '+' || c == '-' { - return time.Parse(timetzFormat2, s) - } - if c := s[l-3]; c == '+' || c == '-' { - return time.Parse(timetzFormat3, s) - } - if c := s[l-9]; c == '+' || c == '-' { - return time.Parse(timetzFormat1, s) - } - } - - if l < len("15:04:05") { - return time.Time{}, fmt.Errorf("bun: can't parse time=%q", s) - } - - if s[2] == ':' { - return time.ParseInLocation(timeFormat, s, time.UTC) - } - return time.ParseInLocation(dateFormat, s, time.UTC) -} diff --git a/vendor/github.com/uptrace/bun/internal/underscore.go b/vendor/github.com/uptrace/bun/internal/underscore.go deleted file mode 100644 index 9de52fb7b..000000000 --- a/vendor/github.com/uptrace/bun/internal/underscore.go +++ /dev/null @@ -1,67 +0,0 @@ -package internal - -func IsUpper(c byte) bool { - return c >= 'A' && c <= 'Z' -} - -func IsLower(c byte) bool { - return c >= 'a' && c <= 'z' -} - -func ToUpper(c byte) byte { - return c - 32 -} - -func ToLower(c byte) byte { - return c + 32 -} - -// Underscore converts "CamelCasedString" to "camel_cased_string". -func Underscore(s string) string { - r := make([]byte, 0, len(s)+5) - for i := 0; i < len(s); i++ { - c := s[i] - if IsUpper(c) { - if i > 0 && i+1 < len(s) && (IsLower(s[i-1]) || IsLower(s[i+1])) { - r = append(r, '_', ToLower(c)) - } else { - r = append(r, ToLower(c)) - } - } else { - r = append(r, c) - } - } - return string(r) -} - -func CamelCased(s string) string { - r := make([]byte, 0, len(s)) - upperNext := true - for i := 0; i < len(s); i++ { - c := s[i] - if c == '_' { - upperNext = true - continue - } - if upperNext { - if IsLower(c) { - c = ToUpper(c) - } - upperNext = false - } - r = append(r, c) - } - return string(r) -} - -func ToExported(s string) string { - if len(s) == 0 { - return s - } - if c := s[0]; IsLower(c) { - b := []byte(s) - b[0] = ToUpper(c) - return string(b) - } - return s -} diff --git a/vendor/github.com/uptrace/bun/internal/unsafe.go b/vendor/github.com/uptrace/bun/internal/unsafe.go deleted file mode 100644 index 1a0331297..000000000 --- a/vendor/github.com/uptrace/bun/internal/unsafe.go +++ /dev/null @@ -1,22 +0,0 @@ -//go:build !appengine -// +build !appengine - -package internal - -import "unsafe" - -// String converts byte slice to string. -func String(b []byte) string { - if len(b) == 0 { - return "" - } - return unsafe.String(&b[0], len(b)) -} - -// Bytes converts string to byte slice. -func Bytes(s string) []byte { - if s == "" { - return []byte{} - } - return unsafe.Slice(unsafe.StringData(s), len(s)) -} diff --git a/vendor/github.com/uptrace/bun/internal/util.go b/vendor/github.com/uptrace/bun/internal/util.go deleted file mode 100644 index ba1341e61..000000000 --- a/vendor/github.com/uptrace/bun/internal/util.go +++ /dev/null @@ -1,87 +0,0 @@ -package internal - -import ( - "reflect" -) - -func MakeSliceNextElemFunc(v reflect.Value) func() reflect.Value { - if v.Kind() == reflect.Array { - var pos int - return func() reflect.Value { - v := v.Index(pos) - pos++ - return v - } - } - - elemType := v.Type().Elem() - - if elemType.Kind() == reflect.Ptr { - elemType = elemType.Elem() - return func() reflect.Value { - if v.Len() < v.Cap() { - v.Set(v.Slice(0, v.Len()+1)) - elem := v.Index(v.Len() - 1) - if elem.IsNil() { - elem.Set(reflect.New(elemType)) - } - return elem - } - - elem := reflect.New(elemType) - v.Set(reflect.Append(v, elem)) - return elem - } - } - - zero := reflect.Zero(elemType) - return func() reflect.Value { - if v.Len() < v.Cap() { - v.Set(v.Slice(0, v.Len()+1)) - return v.Index(v.Len() - 1) - } - - v.Set(reflect.Append(v, zero)) - return v.Index(v.Len() - 1) - } -} - -func Unwrap(err error) error { - u, ok := err.(interface { - Unwrap() error - }) - if !ok { - return nil - } - return u.Unwrap() -} - -func FieldByIndexAlloc(v reflect.Value, index []int) reflect.Value { - if len(index) == 1 { - return v.Field(index[0]) - } - - for i, idx := range index { - if i > 0 { - v = indirectNil(v) - } - v = v.Field(idx) - } - return v -} - -func indirectNil(v reflect.Value) reflect.Value { - if v.Kind() == reflect.Ptr { - if v.IsNil() { - v.Set(reflect.New(v.Type().Elem())) - } - v = v.Elem() - } - return v -} - -// MakeQueryBytes returns zero-length byte slice with capacity of 4096. -func MakeQueryBytes() []byte { - // TODO: make this configurable? - return make([]byte, 0, 4096) -} |