Skip to content

Commit a6d19c7

Browse files
committed
pluralize table name correct
1 parent c414c1c commit a6d19c7

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

generators/file_generator.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"github.com/bitquery/protobuf-sql/compiler/protogen"
77
"github.com/bitquery/protobuf-sql/reflect/protoreflect"
8+
"github.com/gertd/go-pluralize"
89
"github.com/stoewer/go-strcase"
910
"html/template"
1011
"strings"
@@ -165,5 +166,6 @@ func fileName(messageName, suffix string) string {
165166
}
166167

167168
func tableName(messageName, suffix string) string {
168-
return strcase.SnakeCase(strings.TrimSuffix(messageName, suffix)) + "s"
169+
singular := strcase.SnakeCase(strings.TrimSuffix(messageName, suffix))
170+
return pluralize.NewClient().Plural(singular)
169171
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/bitquery/protobuf-sql
33
go 1.17
44

55
require (
6+
github.com/gertd/go-pluralize v0.2.1
67
github.com/golang/protobuf v1.5.3
78
github.com/google/go-cmp v0.5.9
89
github.com/stoewer/go-strcase v1.2.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/gertd/go-pluralize v0.2.1 h1:M3uASbVjMnTsPb0PNqg+E/24Vwigyo/tvyMTtAlLgiA=
5+
github.com/gertd/go-pluralize v0.2.1/go.mod h1:rbYaKDbsXxmRfr8uygAEKhOWsjyrrqrkHVpZvoOp8zk=
46
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
57
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
68
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=

0 commit comments

Comments
 (0)