ran gofmt and did some minor tweaks to satisfy CodeClimate

This commit is contained in:
Adrian 2018-02-09 00:16:43 +08:00
parent 300cf4acd7
commit e8fa95420f

View File

@ -1,11 +1,11 @@
package gorm package gorm
import ( import (
"encoding/json"
"fmt" "fmt"
"reflect" "reflect"
"strings" "strings"
"time" "time"
"encoding/json"
) )
type postgres struct { type postgres struct {
@ -68,12 +68,14 @@ func (s *postgres) DataTypeOf(field *StructField) string {
} }
default: default:
if IsByteArrayOrSlice(dataValue) { if IsByteArrayOrSlice(dataValue) {
sqlType = "bytea"
if isUUID(dataValue) { if isUUID(dataValue) {
sqlType = "uuid" sqlType = "uuid"
} else if isJSON(dataValue) { }
if isJSON(dataValue) {
sqlType = "jsonb" sqlType = "jsonb"
} else {
sqlType = "bytea"
} }
} }
} }
@ -136,9 +138,6 @@ func isUUID(value reflect.Value) bool {
} }
func isJSON(value reflect.Value) bool { func isJSON(value reflect.Value) bool {
if _, ok := value.Interface().(json.RawMessage); ok { _, ok := value.Interface().(json.RawMessage)
return true return ok
} else {
return false
}
} }