Randomize for uniqueidentifier data type

This commit is contained in:
Sergey Kurt 2017-03-16 11:30:07 +03:00
parent 2e9535d56e
commit 5bc7addb8a

View file

@ -52,7 +52,7 @@ var (
rgxValidTime = regexp.MustCompile(`[2-9]+`) rgxValidTime = regexp.MustCompile(`[2-9]+`)
validatedTypes = []string{ validatedTypes = []string{
"inet", "line", "uuid", "interval", "mediumint", "inet", "line", "uuid", "uniqueidentifier", "interval", "mediumint",
"json", "jsonb", "box", "cidr", "circle", "json", "jsonb", "box", "cidr", "circle",
"lseg", "macaddr", "path", "pg_lsn", "point", "lseg", "macaddr", "path", "pg_lsn", "point",
"polygon", "txid_snapshot", "money", "hstore", "polygon", "txid_snapshot", "money", "hstore",
@ -195,7 +195,7 @@ func randomizeField(s *Seed, field reflect.Value, fieldType string, canBeNull bo
field.Set(reflect.ValueOf(value)) field.Set(reflect.ValueOf(value))
return nil return nil
} }
if fieldType == "uuid" { if fieldType == "uuid" || fieldType == "uniqueidentifier" {
value = null.NewString(uuid.NewV4().String(), true) value = null.NewString(uuid.NewV4().String(), true)
field.Set(reflect.ValueOf(value)) field.Set(reflect.ValueOf(value))
return nil return nil
@ -268,7 +268,7 @@ func randomizeField(s *Seed, field reflect.Value, fieldType string, canBeNull bo
field.Set(reflect.ValueOf(value)) field.Set(reflect.ValueOf(value))
return nil return nil
} }
if fieldType == "uuid" { if fieldType == "uuid" || fieldType == "uniqueidentifier" {
value = uuid.NewV4().String() value = uuid.NewV4().String()
field.Set(reflect.ValueOf(value)) field.Set(reflect.ValueOf(value))
return nil return nil
@ -390,7 +390,7 @@ func getArrayRandValue(s *Seed, typ reflect.Type, fieldType string) interface{}
value := strconv.Itoa((s.nextInt()%26)+2) + " days" value := strconv.Itoa((s.nextInt()%26)+2) + " days"
return types.StringArray{value, value} return types.StringArray{value, value}
} }
if fieldType == "uuid" { if fieldType == "uuid" || fieldType == "uniqueidentifier" {
value := uuid.NewV4().String() value := uuid.NewV4().String()
return types.StringArray{value, value} return types.StringArray{value, value}
} }