Merge pull request #708 from pacificporter/is_byte_array_or_slice

Fix SqlTag() in case of ByteSlice
This commit is contained in:
Jinzhu 2015-10-31 18:12:38 +08:00
commit 67f88d977b
1 changed files with 3 additions and 3 deletions

View File

@ -53,7 +53,7 @@ func (postgres) SqlTag(value reflect.Value, size int, autoIncrease bool) string
return "hstore"
}
default:
if isByteArray(value) {
if isByteArrayOrSlice(value) {
if isUUID(value) {
return "uuid"
}
@ -65,8 +65,8 @@ func (postgres) SqlTag(value reflect.Value, size int, autoIncrease bool) string
var byteType = reflect.TypeOf(uint8(0))
func isByteArray(value reflect.Value) bool {
return value.Kind() == reflect.Array && value.Type().Elem() == byteType
func isByteArrayOrSlice(value reflect.Value) bool {
return (value.Kind() == reflect.Array || value.Kind() == reflect.Slice) && value.Type().Elem() == byteType
}
func isUUID(value reflect.Value) bool {