From 5bc7addb8ac25d720a1fc8a5aca2ca877dea5c63 Mon Sep 17 00:00:00 2001 From: Sergey Kurt Date: Thu, 16 Mar 2017 11:30:07 +0300 Subject: [PATCH] Randomize for uniqueidentifier data type --- randomize/randomize.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/randomize/randomize.go b/randomize/randomize.go index 59f7eff..2af945d 100644 --- a/randomize/randomize.go +++ b/randomize/randomize.go @@ -52,7 +52,7 @@ var ( rgxValidTime = regexp.MustCompile(`[2-9]+`) validatedTypes = []string{ - "inet", "line", "uuid", "interval", "mediumint", + "inet", "line", "uuid", "uniqueidentifier", "interval", "mediumint", "json", "jsonb", "box", "cidr", "circle", "lseg", "macaddr", "path", "pg_lsn", "point", "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)) return nil } - if fieldType == "uuid" { + if fieldType == "uuid" || fieldType == "uniqueidentifier" { value = null.NewString(uuid.NewV4().String(), true) field.Set(reflect.ValueOf(value)) return nil @@ -268,7 +268,7 @@ func randomizeField(s *Seed, field reflect.Value, fieldType string, canBeNull bo field.Set(reflect.ValueOf(value)) return nil } - if fieldType == "uuid" { + if fieldType == "uuid" || fieldType == "uniqueidentifier" { value = uuid.NewV4().String() field.Set(reflect.ValueOf(value)) return nil @@ -390,7 +390,7 @@ func getArrayRandValue(s *Seed, typ reflect.Type, fieldType string) interface{} value := strconv.Itoa((s.nextInt()%26)+2) + " days" return types.StringArray{value, value} } - if fieldType == "uuid" { + if fieldType == "uuid" || fieldType == "uniqueidentifier" { value := uuid.NewV4().String() return types.StringArray{value, value} }