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 (
|
var (
|
||||||
idAlphabet = []byte("abcdefghijklmnopqrstuvwxyz")
|
idAlphabet = []byte("abcdefghijklmnopqrstuvwxyz")
|
||||||
uppercaseWords = []*regexp.Regexp{
|
uppercaseWords = regexp.MustCompile(`^(?i)(id|uid|uuid|guid|ssn|tz)[0-9]*$`)
|
||||||
regexp.MustCompile(`^id[0-9]*$`),
|
smartQuoteRgx = regexp.MustCompile(`^(?i)"?[a-z_][_a-z0-9]*"?(\."?[_a-z][_a-z0-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]*"?)*$`)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// IdentQuote attempts to quote simple identifiers in SQL tatements
|
// IdentQuote attempts to quote simple identifiers in SQL tatements
|
||||||
|
@ -95,16 +88,8 @@ func TitleCase(name string) string {
|
||||||
splits := strings.Split(name, "_")
|
splits := strings.Split(name, "_")
|
||||||
|
|
||||||
for i, split := range splits {
|
for i, split := range splits {
|
||||||
found := false
|
if uppercaseWords.MatchString(split) {
|
||||||
for _, uc := range uppercaseWords {
|
splits[i] = strings.ToUpper(split)
|
||||||
if uc.MatchString(split) {
|
|
||||||
splits[i] = strings.ToUpper(split)
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if found {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,21 +111,13 @@ func CamelCase(name string) string {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
found := false
|
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
for _, uc := range uppercaseWords {
|
if uppercaseWords.MatchString(split) {
|
||||||
if uc.MatchString(split) {
|
splits[i] = strings.ToUpper(split)
|
||||||
splits[i] = strings.ToUpper(split)
|
continue
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if found {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
splits[i] = strings.Title(split)
|
splits[i] = strings.Title(split)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue