mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: make enum names pascal case regadless of value case
Signed-off-by: Alex Snast <alexsn@fb.com>
This commit is contained in:
@@ -64,7 +64,7 @@ var (
|
||||
"list": list,
|
||||
}
|
||||
rules = ruleset()
|
||||
acronyms = make(map[string]bool)
|
||||
acronyms = make(map[string]struct{})
|
||||
)
|
||||
|
||||
// ops returns all operations for given field.
|
||||
@@ -114,7 +114,7 @@ func pascal(s string) string {
|
||||
words := strings.Split(s, "_")
|
||||
for i, w := range words {
|
||||
upper := strings.ToUpper(w)
|
||||
if acronyms[upper] {
|
||||
if _, ok := acronyms[upper]; ok {
|
||||
words[i] = upper
|
||||
} else {
|
||||
words[i] = rules.Capitalize(w)
|
||||
@@ -258,7 +258,7 @@ func ruleset() *inflect.Ruleset {
|
||||
"TLS", "TTL", "UDP", "UI", "UID", "URI", "URL", "UTF8", "UUID", "VM",
|
||||
"XML", "XMPP", "XSRF", "XSS",
|
||||
} {
|
||||
acronyms[w] = true
|
||||
acronyms[w] = struct{}{}
|
||||
rules.AddAcronym(w)
|
||||
}
|
||||
return rules
|
||||
|
||||
@@ -615,7 +615,7 @@ func (f Field) Enums() []string {
|
||||
|
||||
// EnumName returns the constant name of the enum value.
|
||||
func (f Field) EnumName(enum string) string {
|
||||
return pascal(f.Name) + pascal(enum)
|
||||
return pascal(f.Name) + pascal(strings.ToLower(enum))
|
||||
}
|
||||
|
||||
// Validator returns the validator name.
|
||||
|
||||
Reference in New Issue
Block a user