Skip to content

Commit

Permalink
fix: make the entity names always lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
fdemir committed Jan 2, 2024
1 parent c755dcc commit 090d8ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ func parseSource(src io.Reader) []Entity {
case currentAttribute != nil && currentAttribute.Type == "":
currentAttribute.Type = text

// is valid faker method

typeParts := strings.Split(currentAttribute.Type, ".")

if len(typeParts) == 2 {
Expand Down Expand Up @@ -106,8 +104,10 @@ func generateFake(entities []Entity) map[string]*[]interface{} {
fakerValue := reflect.ValueOf(fake)

for _, entity := range entities {
lowercasedEntityName := strings.ToLower(entity.Name)

entityResults := make([]interface{}, 0, RECORD_COUNT)
resultList[entity.Name] = &entityResults
resultList[lowercasedEntityName] = &entityResults

for i := 0; i < RECORD_COUNT; i++ {
fakeValues := make(map[string]any)
Expand All @@ -126,7 +126,7 @@ func generateFake(entities []Entity) map[string]*[]interface{} {
fakeValues[attr.Name] = method.Call([]reflect.Value{})[0].Interface()
}

*resultList[entity.Name] = append(*resultList[entity.Name], fakeValues)
*resultList[lowercasedEntityName] = append(*resultList[lowercasedEntityName], fakeValues)
}
}

Expand Down

0 comments on commit 090d8ed

Please sign in to comment.