forked from sqlc-dev/sqlc-gen-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingular.go
More file actions
36 lines (31 loc) · 774 Bytes
/
singular.go
File metadata and controls
36 lines (31 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package inflection
import (
"strings"
upstream "github.com/jinzhu/inflection"
)
type SingularParams struct {
Name string
Exclusions []string
}
func Singular(s SingularParams) string {
for _, exclusion := range s.Exclusions {
if strings.EqualFold(s.Name, exclusion) {
return s.Name
}
}
// Manual fix for incorrect handling of "campus"
//
// https://github.com/kyleconroy/sqlc/issues/430
// https://github.com/jinzhu/inflection/issues/13
if strings.ToLower(s.Name) == "campus" {
return s.Name
}
// Manual fix for incorrect handling of "meta"
//
// https://github.com/kyleconroy/sqlc/issues/1217
// https://github.com/jinzhu/inflection/issues/21
if strings.ToLower(s.Name) == "meta" {
return s.Name
}
return upstream.Singular(s.Name)
}