Remove package name from txt helpers
This commit is contained in:
parent
81494a91d0
commit
be189323d9
2 changed files with 6 additions and 11 deletions
|
@ -27,7 +27,6 @@ type TxtToOne struct {
|
|||
}
|
||||
|
||||
Function struct {
|
||||
PackageName string
|
||||
Name string
|
||||
ForeignName string
|
||||
|
||||
|
@ -40,7 +39,7 @@ type TxtToOne struct {
|
|||
}
|
||||
}
|
||||
|
||||
func txtsFromFKey(packageName string, tables []bdb.Table, table bdb.Table, fkey bdb.ForeignKey) TxtToOne {
|
||||
func txtsFromFKey(tables []bdb.Table, table bdb.Table, fkey bdb.ForeignKey) TxtToOne {
|
||||
r := TxtToOne{}
|
||||
|
||||
r.ForeignKey = fkey
|
||||
|
@ -54,7 +53,6 @@ func txtsFromFKey(packageName string, tables []bdb.Table, table bdb.Table, fkey
|
|||
r.ForeignTable.ColumnName = fkey.ForeignColumn
|
||||
r.ForeignTable.ColumnNameGo = strmangle.TitleCase(strmangle.Singular(fkey.ForeignColumn))
|
||||
|
||||
r.Function.PackageName = packageName
|
||||
r.Function.Name = strmangle.TitleCase(strmangle.Singular(strings.TrimSuffix(fkey.Column, "_id")))
|
||||
plurality := strmangle.Plural
|
||||
if fkey.Unique {
|
||||
|
@ -85,7 +83,7 @@ func txtsFromFKey(packageName string, tables []bdb.Table, table bdb.Table, fkey
|
|||
return r
|
||||
}
|
||||
|
||||
func txtsFromOneToOne(packageName string, tables []bdb.Table, table bdb.Table, oneToOne bdb.ToOneRelationship) TxtToOne {
|
||||
func txtsFromOneToOne(tables []bdb.Table, table bdb.Table, oneToOne bdb.ToOneRelationship) TxtToOne {
|
||||
fkey := bdb.ForeignKey{
|
||||
Table: oneToOne.Table,
|
||||
Name: "none",
|
||||
|
@ -99,7 +97,7 @@ func txtsFromOneToOne(packageName string, tables []bdb.Table, table bdb.Table, o
|
|||
ForeignColumnUnique: oneToOne.ForeignColumnUnique,
|
||||
}
|
||||
|
||||
rel := txtsFromFKey(packageName, tables, table, fkey)
|
||||
rel := txtsFromFKey(tables, table, fkey)
|
||||
col := table.GetColumn(oneToOne.Column)
|
||||
|
||||
// Reverse foreign key
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestTxtsFromOne(t *testing.T) {
|
|||
}
|
||||
|
||||
jets := bdb.GetTable(tables, "jets")
|
||||
texts := txtsFromFKey("models", tables, jets, jets.FKeys[0])
|
||||
texts := txtsFromFKey(tables, jets, jets.FKeys[0])
|
||||
expect := TxtToOne{}
|
||||
|
||||
expect.ForeignKey = jets.FKeys[0]
|
||||
|
@ -32,7 +32,6 @@ func TestTxtsFromOne(t *testing.T) {
|
|||
expect.ForeignTable.ColumnName = "id"
|
||||
expect.ForeignTable.ColumnNameGo = "ID"
|
||||
|
||||
expect.Function.PackageName = "models"
|
||||
expect.Function.Name = "Pilot"
|
||||
expect.Function.ForeignName = "Jet"
|
||||
expect.Function.Varname = "pilot"
|
||||
|
@ -45,7 +44,7 @@ func TestTxtsFromOne(t *testing.T) {
|
|||
t.Errorf("Want:\n%s\nGot:\n%s\n", spew.Sdump(expect), spew.Sdump(texts))
|
||||
}
|
||||
|
||||
texts = txtsFromFKey("models", tables, jets, jets.FKeys[1])
|
||||
texts = txtsFromFKey(tables, jets, jets.FKeys[1])
|
||||
expect = TxtToOne{}
|
||||
expect.ForeignKey = jets.FKeys[1]
|
||||
|
||||
|
@ -58,7 +57,6 @@ func TestTxtsFromOne(t *testing.T) {
|
|||
expect.ForeignTable.ColumnName = "id"
|
||||
expect.ForeignTable.ColumnNameGo = "ID"
|
||||
|
||||
expect.Function.PackageName = "models"
|
||||
expect.Function.Name = "Airport"
|
||||
expect.Function.ForeignName = "Jets"
|
||||
expect.Function.Varname = "airport"
|
||||
|
@ -85,7 +83,7 @@ func TestTxtsFromOneToOne(t *testing.T) {
|
|||
}
|
||||
|
||||
pilots := bdb.GetTable(tables, "pilots")
|
||||
texts := txtsFromOneToOne("models", tables, pilots, pilots.ToOneRelationships[0])
|
||||
texts := txtsFromOneToOne(tables, pilots, pilots.ToOneRelationships[0])
|
||||
expect := TxtToOne{}
|
||||
|
||||
expect.ForeignKey = bdb.ForeignKey{
|
||||
|
@ -111,7 +109,6 @@ func TestTxtsFromOneToOne(t *testing.T) {
|
|||
expect.ForeignTable.ColumnName = "pilot_id"
|
||||
expect.ForeignTable.ColumnNameGo = "PilotID"
|
||||
|
||||
expect.Function.PackageName = "models"
|
||||
expect.Function.Name = "Jet"
|
||||
expect.Function.ForeignName = "Pilot"
|
||||
expect.Function.Varname = "jet"
|
||||
|
|
Loading…
Reference in a new issue