Make relationships output the column name
This commit is contained in:
parent
4412026e63
commit
c7eafa4e08
2 changed files with 4 additions and 3 deletions
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue