upstep bun version (#243)

This commit is contained in:
tobi 2021-09-23 11:13:28 +02:00 committed by GitHub
commit 142f37f1bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 146 additions and 57 deletions

View file

@ -6,9 +6,11 @@ import (
"net"
"reflect"
"strconv"
"strings"
"time"
"github.com/uptrace/bun/dialect"
"github.com/uptrace/bun/dialect/sqltype"
"github.com/uptrace/bun/extra/bunjson"
"github.com/uptrace/bun/internal"
)
@ -47,6 +49,19 @@ var appenders = []AppenderFunc{
reflect.UnsafePointer: nil,
}
func FieldAppender(dialect Dialect, field *Field) AppenderFunc {
if field.Tag.HasOption("msgpack") {
return appendMsgpack
}
switch strings.ToUpper(field.UserSQLType) {
case sqltype.JSON, sqltype.JSONB:
return AppendJSONValue
}
return dialect.Appender(field.StructField.Type)
}
func Appender(typ reflect.Type, custom CustomAppender) AppenderFunc {
switch typ {
case bytesType: