DataTypeOf should now correctly identify dataValues that are 'json.RawMessage' types as 'jsonb' columns
This commit is contained in:
parent
87fc1b2473
commit
feb013c976
@ -5,6 +5,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type postgres struct {
|
type postgres struct {
|
||||||
@ -67,9 +68,12 @@ 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 _, ok := dataValue.Interface().(json.RawMessage); ok {
|
||||||
|
sqlType = "jsonb"
|
||||||
|
} else {
|
||||||
|
sqlType = "bytea"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user