mirror of https://github.com/go-gorm/gorm.git
Fix SqlTag() in case of ByteSlice
This commit is contained in:
parent
0589d36e64
commit
92f9584c83
|
@ -53,7 +53,7 @@ func (postgres) SqlTag(value reflect.Value, size int, autoIncrease bool) string
|
||||||
return "hstore"
|
return "hstore"
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if isByteArray(value) {
|
if isByteArrayOrSlice(value) {
|
||||||
if isUUID(value) {
|
if isUUID(value) {
|
||||||
return "uuid"
|
return "uuid"
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,8 @@ func (postgres) SqlTag(value reflect.Value, size int, autoIncrease bool) string
|
||||||
|
|
||||||
var byteType = reflect.TypeOf(uint8(0))
|
var byteType = reflect.TypeOf(uint8(0))
|
||||||
|
|
||||||
func isByteArray(value reflect.Value) bool {
|
func isByteArrayOrSlice(value reflect.Value) bool {
|
||||||
return value.Kind() == reflect.Array && value.Type().Elem() == byteType
|
return (value.Kind() == reflect.Array || value.Kind() == reflect.Slice) && value.Type().Elem() == byteType
|
||||||
}
|
}
|
||||||
|
|
||||||
func isUUID(value reflect.Value) bool {
|
func isUUID(value reflect.Value) bool {
|
||||||
|
|
Loading…
Reference in New Issue