diff --git a/bdb/relationships.go b/bdb/relationships.go index 36a06e2..b7f194f 100644 --- a/bdb/relationships.go +++ b/bdb/relationships.go @@ -4,7 +4,7 @@ package bdb // local table has no id, and the foreign table has an id that matches a column // in the local table. type ToManyRelationship struct { - Name string + Column string ForeignTable string ForeignColumn string } @@ -28,6 +28,7 @@ func ToManyRelationships(table string, tables []Table) []ToManyRelationship { // standardColName := fmt.Sprintf("%s_id", singularName) relationship := ToManyRelationship{ + Column: f.ForeignColumn, ForeignTable: t.Name, ForeignColumn: f.Column, } diff --git a/bdb/relationships_test.go b/bdb/relationships_test.go index b1055c8..912dd97 100644 --- a/bdb/relationships_test.go +++ b/bdb/relationships_test.go @@ -24,8 +24,8 @@ func TestToManyRelationships(t *testing.T) { relationships := ToManyRelationships("users", tables) r := relationships[0] - if r.Name != "Videos" { - t.Error("wrong name:", r.Name) + if r.Column != "id" { + t.Error("wrong local column:", r.Column) } if r.ForeignTable != "videos" { t.Error("wrong foreign table:", r.ForeignTable)