Fix silly regexp pattern
This commit is contained in:
parent
afedc92224
commit
0a2507178e
1 changed files with 7 additions and 30 deletions
|
@ -15,15 +15,8 @@ import (
|
|||
|
||||
var (
|
||||
idAlphabet = []byte("abcdefghijklmnopqrstuvwxyz")
|
||||
uppercaseWords = []*regexp.Regexp{
|
||||
regexp.MustCompile(`^id[0-9]*$`),
|
||||
regexp.MustCompile(`^uid[0-9]*$`),
|
||||
regexp.MustCompile(`^uuid[0-9]*$`),
|
||||
regexp.MustCompile(`^guid[0-9]*$`),
|
||||
regexp.MustCompile(`^ssn[0-9]*$`),
|
||||
regexp.MustCompile(`^tz[0-9]*$`),
|
||||
}
|
||||
smartQuoteRgx = regexp.MustCompile(`^(?i)"?[a-z_][_a-z0-9]*"?(\."?[_a-z][_a-z0-9]*"?)*$`)
|
||||
uppercaseWords = regexp.MustCompile(`^(?i)(id|uid|uuid|guid|ssn|tz)[0-9]*$`)
|
||||
smartQuoteRgx = regexp.MustCompile(`^(?i)"?[a-z_][_a-z0-9]*"?(\."?[_a-z][_a-z0-9]*"?)*$`)
|
||||
)
|
||||
|
||||
// IdentQuote attempts to quote simple identifiers in SQL tatements
|
||||
|
@ -95,16 +88,8 @@ func TitleCase(name string) string {
|
|||
splits := strings.Split(name, "_")
|
||||
|
||||
for i, split := range splits {
|
||||
found := false
|
||||
for _, uc := range uppercaseWords {
|
||||
if uc.MatchString(split) {
|
||||
splits[i] = strings.ToUpper(split)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if found {
|
||||
if uppercaseWords.MatchString(split) {
|
||||
splits[i] = strings.ToUpper(split)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -126,21 +111,13 @@ func CamelCase(name string) string {
|
|||
continue
|
||||
}
|
||||
|
||||
found := false
|
||||
if i > 0 {
|
||||
for _, uc := range uppercaseWords {
|
||||
if uc.MatchString(split) {
|
||||
splits[i] = strings.ToUpper(split)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
if uppercaseWords.MatchString(split) {
|
||||
splits[i] = strings.ToUpper(split)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if found {
|
||||
continue
|
||||
}
|
||||
|
||||
splits[i] = strings.Title(split)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue