Skip to content

Commit

Permalink
Minor cleanup to logic in buildQueryName
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshaw committed Jul 28, 2021
1 parent 739c03d commit 43f43ab
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions templates/gotpl/gotpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,23 +307,23 @@ func buildQueryType(ctx context.Context, query xo.Query) (Table, error) {
}, nil
}

// buildQueryName builds a name for the query.
func buildQueryName(query xo.Query) string {
name := query.Name
if name == "" {
// no func name specified, so generate based on type
if query.One {
name = query.Type
} else {
name = inflector.Pluralize(query.Type)
}
// affix any params
if len(query.Params) == 0 {
name = "Get" + name
} else {
name += "By"
for _, p := range query.Params {
name += snaker.ForceCamelIdentifier(p.Name)
}
if query.Name != "" {
return query.Name
}
// generate name if not specified
name := query.Type
if !query.One {
name = inflector.Pluralize(name)
}
// add params
if len(query.Params) == 0 {
name = "Get" + name
} else {
name += "By"
for _, p := range query.Params {
name += snaker.ForceCamelIdentifier(p.Name)
}
}
return name
Expand Down

0 comments on commit 43f43ab

Please sign in to comment.