Add nullability to foreign keys.
- Remove some debug output. - Add some parallel
This commit is contained in:
parent
7863284e61
commit
104d0e57cd
5 changed files with 57 additions and 10 deletions
|
@ -14,7 +14,7 @@ func (t testInterface) TableNames() ([]string, error) {
|
|||
func (t testInterface) Columns(tableName string) ([]Column, error) {
|
||||
return []Column{
|
||||
Column{Name: "col1", Type: "character varying"},
|
||||
Column{Name: "col2", Type: "character varying"},
|
||||
Column{Name: "col2", Type: "character varying", IsNullable: true},
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func TestTables(t *testing.T) {
|
|||
|
||||
expectCols := []Column{
|
||||
Column{Name: "col1", Type: "string"},
|
||||
Column{Name: "col2", Type: "string"},
|
||||
Column{Name: "col2", Type: "string", IsNullable: true},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(tables[0].Columns, expectCols) {
|
||||
|
@ -88,6 +88,7 @@ func TestTables(t *testing.T) {
|
|||
Column: "col2",
|
||||
ForeignTable: "table3",
|
||||
ForeignColumn: "col3",
|
||||
Nullable: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -132,3 +133,31 @@ func TestSetIsJoinTable(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetForeignKeyNullability(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
table := &Table{
|
||||
Columns: []Column{
|
||||
Column{Name: "col1", Type: "string"},
|
||||
Column{Name: "col2", Type: "string", IsNullable: true},
|
||||
},
|
||||
FKeys: []ForeignKey{
|
||||
{
|
||||
Column: "col1",
|
||||
},
|
||||
{
|
||||
Column: "col2",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
setForeignKeyNullability(table)
|
||||
|
||||
if table.FKeys[0].Nullable {
|
||||
t.Error("should not be nullable")
|
||||
}
|
||||
if !table.FKeys[1].Nullable {
|
||||
t.Error("should be nullable")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue