gotosocial/vendor/github.com/uptrace/bun/schema/reflect.go
dependabot[bot] afd5f8a80a
[chore]: Bump github.com/uptrace/bun/dialect/sqlitedialect
Bumps [github.com/uptrace/bun/dialect/sqlitedialect](https://github.com/uptrace/bun) from 1.2.6 to 1.2.8.
- [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.6...v1.2.8)

---
updated-dependencies:
- dependency-name: github.com/uptrace/bun/dialect/sqlitedialect
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-14 13:12:59 +00:00

51 lines
1.1 KiB
Go

package schema
import (
"database/sql/driver"
"encoding/json"
"net"
"net/netip"
"reflect"
"time"
)
var (
bytesType = reflect.TypeFor[[]byte]()
timePtrType = reflect.TypeFor[*time.Time]()
timeType = reflect.TypeFor[time.Time]()
ipType = reflect.TypeFor[net.IP]()
ipNetType = reflect.TypeFor[net.IPNet]()
netipPrefixType = reflect.TypeFor[netip.Prefix]()
netipAddrType = reflect.TypeFor[netip.Addr]()
jsonRawMessageType = reflect.TypeFor[json.RawMessage]()
driverValuerType = reflect.TypeFor[driver.Valuer]()
queryAppenderType = reflect.TypeFor[QueryAppender]()
jsonMarshalerType = reflect.TypeFor[json.Marshaler]()
)
func indirectType(t reflect.Type) reflect.Type {
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
return t
}
func fieldByIndex(v reflect.Value, index []int) (_ reflect.Value, ok bool) {
if len(index) == 1 {
return v.Field(index[0]), true
}
for i, idx := range index {
if i > 0 {
if v.Kind() == reflect.Ptr {
if v.IsNil() {
return v, false
}
v = v.Elem()
}
}
v = v.Field(idx)
}
return v, true
}