move the json check to its own function
This commit is contained in:
parent
feb013c976
commit
300cf4acd7
@ -70,7 +70,7 @@ func (s *postgres) DataTypeOf(field *StructField) string {
|
|||||||
if IsByteArrayOrSlice(dataValue) {
|
if IsByteArrayOrSlice(dataValue) {
|
||||||
if isUUID(dataValue) {
|
if isUUID(dataValue) {
|
||||||
sqlType = "uuid"
|
sqlType = "uuid"
|
||||||
} else if _, ok := dataValue.Interface().(json.RawMessage); ok {
|
} else if isJSON(dataValue) {
|
||||||
sqlType = "jsonb"
|
sqlType = "jsonb"
|
||||||
} else {
|
} else {
|
||||||
sqlType = "bytea"
|
sqlType = "bytea"
|
||||||
@ -134,3 +134,11 @@ func isUUID(value reflect.Value) bool {
|
|||||||
lower := strings.ToLower(typename)
|
lower := strings.ToLower(typename)
|
||||||
return "uuid" == lower || "guid" == lower
|
return "uuid" == lower || "guid" == lower
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isJSON(value reflect.Value) bool {
|
||||||
|
if _, ok := value.Interface().(json.RawMessage); ok {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user