diff --git a/dialect_postgres.go b/dialect_postgres.go index 058e6e27..5cce1c9e 100644 --- a/dialect_postgres.go +++ b/dialect_postgres.go @@ -70,7 +70,7 @@ func (s *postgres) DataTypeOf(field *StructField) string { if IsByteArrayOrSlice(dataValue) { if isUUID(dataValue) { sqlType = "uuid" - } else if _, ok := dataValue.Interface().(json.RawMessage); ok { + } else if isJSON(dataValue) { sqlType = "jsonb" } else { sqlType = "bytea" @@ -134,3 +134,11 @@ func isUUID(value reflect.Value) bool { lower := strings.ToLower(typename) return "uuid" == lower || "guid" == lower } + +func isJSON(value reflect.Value) bool { + if _, ok := value.Interface().(json.RawMessage); ok { + return true + } else { + return false + } +}