DataTypeOf should now correctly identify dataValues that are 'json.RawMessage' types as 'jsonb' columns

This commit is contained in:
Adrian 2018-02-08 23:58:03 +08:00
parent 87fc1b2473
commit feb013c976

View File

@ -5,6 +5,7 @@ import (
"reflect"
"strings"
"time"
"encoding/json"
)
type postgres struct {
@ -67,9 +68,12 @@ func (s *postgres) DataTypeOf(field *StructField) string {
}
default:
if IsByteArrayOrSlice(dataValue) {
sqlType = "bytea"
if isUUID(dataValue) {
sqlType = "uuid"
} else if _, ok := dataValue.Interface().(json.RawMessage); ok {
sqlType = "jsonb"
} else {
sqlType = "bytea"
}
}
}