Fix more broken code

This commit is contained in:
Aaron L 2016-08-27 17:04:51 -07:00
parent 84e13cf0d4
commit 6c742e29e9
3 changed files with 7 additions and 3 deletions

View file

@ -59,7 +59,7 @@ func (m *MockDriver) Columns(tableName string) ([]bdb.Column, error) {
func (m *MockDriver) ForeignKeyInfo(tableName string) ([]bdb.ForeignKey, error) { func (m *MockDriver) ForeignKeyInfo(tableName string) ([]bdb.ForeignKey, error) {
return map[string][]bdb.ForeignKey{ return map[string][]bdb.ForeignKey{
"jets": { "jets": {
{Table: "jets", Name: "jets_pilot_id_fk", Column: "pilot_id", ForeignTable: "pilots", ForeignColumn: "id"}, {Table: "jets", Name: "jets_pilot_id_fk", Column: "pilot_id", ForeignTable: "pilots", ForeignColumn: "id", ForeignColumnUnique: true},
{Table: "jets", Name: "jets_airport_id_fk", Column: "airport_id", ForeignTable: "airports", ForeignColumn: "id"}, {Table: "jets", Name: "jets_airport_id_fk", Column: "airport_id", ForeignTable: "airports", ForeignColumn: "id"},
}, },
"licenses": { "licenses": {

View file

@ -58,7 +58,7 @@ func buildRelationship(localTable Table, foreignKey ForeignKey, foreignTable Tab
if !foreignTable.IsJoinTable { if !foreignTable.IsJoinTable {
col := localTable.GetColumn(foreignKey.ForeignColumn) col := localTable.GetColumn(foreignKey.ForeignColumn)
return ToManyRelationship{ return ToManyRelationship{
Table: foreignKey.Table, Table: localTable.Name,
Column: foreignKey.ForeignColumn, Column: foreignKey.ForeignColumn,
Nullable: col.Nullable, Nullable: col.Nullable,
Unique: col.Unique, Unique: col.Unique,
@ -72,7 +72,7 @@ func buildRelationship(localTable Table, foreignKey ForeignKey, foreignTable Tab
col := foreignTable.GetColumn(foreignKey.Column) col := foreignTable.GetColumn(foreignKey.Column)
relationship := ToManyRelationship{ relationship := ToManyRelationship{
Table: foreignKey.ForeignTable, Table: localTable.Name,
Column: foreignKey.ForeignColumn, Column: foreignKey.ForeignColumn,
Nullable: col.Nullable, Nullable: col.Nullable,
Unique: col.Unique, Unique: col.Unique,

View file

@ -77,6 +77,7 @@ func TestToManyRelationships(t *testing.T) {
expected := []ToManyRelationship{ expected := []ToManyRelationship{
{ {
Table: "pilots",
Column: "id", Column: "id",
Nullable: false, Nullable: false,
Unique: false, Unique: false,
@ -89,6 +90,7 @@ func TestToManyRelationships(t *testing.T) {
ToJoinTable: false, ToJoinTable: false,
}, },
{ {
Table: "pilots",
Column: "id", Column: "id",
Nullable: false, Nullable: false,
Unique: false, Unique: false,
@ -210,6 +212,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
expected := []ToManyRelationship{ expected := []ToManyRelationship{
{ {
Table: "pilots",
Column: "id", Column: "id",
Nullable: true, Nullable: true,
Unique: true, Unique: true,
@ -222,6 +225,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
ToJoinTable: false, ToJoinTable: false,
}, },
{ {
Table: "pilots",
Column: "id", Column: "id",
Nullable: true, Nullable: true,
Unique: true, Unique: true,