Fix more broken code
This commit is contained in:
parent
84e13cf0d4
commit
6c742e29e9
3 changed files with 7 additions and 3 deletions
|
@ -59,7 +59,7 @@ func (m *MockDriver) Columns(tableName string) ([]bdb.Column, error) {
|
|||
func (m *MockDriver) ForeignKeyInfo(tableName string) ([]bdb.ForeignKey, error) {
|
||||
return map[string][]bdb.ForeignKey{
|
||||
"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"},
|
||||
},
|
||||
"licenses": {
|
||||
|
|
|
@ -58,7 +58,7 @@ func buildRelationship(localTable Table, foreignKey ForeignKey, foreignTable Tab
|
|||
if !foreignTable.IsJoinTable {
|
||||
col := localTable.GetColumn(foreignKey.ForeignColumn)
|
||||
return ToManyRelationship{
|
||||
Table: foreignKey.Table,
|
||||
Table: localTable.Name,
|
||||
Column: foreignKey.ForeignColumn,
|
||||
Nullable: col.Nullable,
|
||||
Unique: col.Unique,
|
||||
|
@ -72,7 +72,7 @@ func buildRelationship(localTable Table, foreignKey ForeignKey, foreignTable Tab
|
|||
|
||||
col := foreignTable.GetColumn(foreignKey.Column)
|
||||
relationship := ToManyRelationship{
|
||||
Table: foreignKey.ForeignTable,
|
||||
Table: localTable.Name,
|
||||
Column: foreignKey.ForeignColumn,
|
||||
Nullable: col.Nullable,
|
||||
Unique: col.Unique,
|
||||
|
|
|
@ -77,6 +77,7 @@ func TestToManyRelationships(t *testing.T) {
|
|||
|
||||
expected := []ToManyRelationship{
|
||||
{
|
||||
Table: "pilots",
|
||||
Column: "id",
|
||||
Nullable: false,
|
||||
Unique: false,
|
||||
|
@ -89,6 +90,7 @@ func TestToManyRelationships(t *testing.T) {
|
|||
ToJoinTable: false,
|
||||
},
|
||||
{
|
||||
Table: "pilots",
|
||||
Column: "id",
|
||||
Nullable: false,
|
||||
Unique: false,
|
||||
|
@ -210,6 +212,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
|
|||
|
||||
expected := []ToManyRelationship{
|
||||
{
|
||||
Table: "pilots",
|
||||
Column: "id",
|
||||
Nullable: true,
|
||||
Unique: true,
|
||||
|
@ -222,6 +225,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
|
|||
ToJoinTable: false,
|
||||
},
|
||||
{
|
||||
Table: "pilots",
|
||||
Column: "id",
|
||||
Nullable: true,
|
||||
Unique: true,
|
||||
|
|
Loading…
Add table
Reference in a new issue