From e8fa95420fa7270d5214c80739c4affa71635eb5 Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 9 Feb 2018 00:16:43 +0800 Subject: [PATCH] ran gofmt and did some minor tweaks to satisfy CodeClimate --- dialect_postgres.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dialect_postgres.go b/dialect_postgres.go index 5cce1c9e..3bcea536 100644 --- a/dialect_postgres.go +++ b/dialect_postgres.go @@ -1,11 +1,11 @@ package gorm import ( + "encoding/json" "fmt" "reflect" "strings" "time" - "encoding/json" ) type postgres struct { @@ -68,12 +68,14 @@ func (s *postgres) DataTypeOf(field *StructField) string { } default: if IsByteArrayOrSlice(dataValue) { + sqlType = "bytea" + if isUUID(dataValue) { sqlType = "uuid" - } else if isJSON(dataValue) { + } + + if isJSON(dataValue) { sqlType = "jsonb" - } else { - sqlType = "bytea" } } } @@ -136,9 +138,6 @@ func isUUID(value reflect.Value) bool { } func isJSON(value reflect.Value) bool { - if _, ok := value.Interface().(json.RawMessage); ok { - return true - } else { - return false - } + _, ok := value.Interface().(json.RawMessage) + return ok }