diff --git a/go/logic/inspect.go b/go/logic/inspect.go index 9d414a43e..42aee7e73 100644 --- a/go/logic/inspect.go +++ b/go/logic/inspect.go @@ -736,8 +736,9 @@ func (this *Inspector) getSharedUniqueKeys(originalUniqueKeys, ghostUniqueKeys [ // the ALTER is on the name itself... for _, originalUniqueKey := range originalUniqueKeys { for _, ghostUniqueKey := range ghostUniqueKeys { - if originalUniqueKey.Columns.EqualsByNames(&ghostUniqueKey.Columns) { + if originalUniqueKey.Columns.IsSubsetOf(&ghostUniqueKey.Columns) { uniqueKeys = append(uniqueKeys, originalUniqueKey) + break } } } diff --git a/go/logic/inspect_test.go b/go/logic/inspect_test.go index 54bc48ff0..4fa1eec11 100644 --- a/go/logic/inspect_test.go +++ b/go/logic/inspect_test.go @@ -17,6 +17,7 @@ func TestInspectGetSharedUniqueKeys(t *testing.T) { origUniqKeys := []*sql.UniqueKey{ {Columns: *sql.NewColumnList([]string{"id", "item_id"})}, {Columns: *sql.NewColumnList([]string{"id", "org_id"})}, + {Columns: *sql.NewColumnList([]string{"id"})}, } ghostUniqKeys := []*sql.UniqueKey{ {Columns: *sql.NewColumnList([]string{"id", "item_id"})}, @@ -25,7 +26,8 @@ func TestInspectGetSharedUniqueKeys(t *testing.T) { } inspector := &Inspector{} sharedUniqKeys := inspector.getSharedUniqueKeys(origUniqKeys, ghostUniqKeys) - test.S(t).ExpectEquals(len(sharedUniqKeys), 2) + test.S(t).ExpectEquals(len(sharedUniqKeys), 3) test.S(t).ExpectEquals(sharedUniqKeys[0].Columns.String(), "id,item_id") test.S(t).ExpectEquals(sharedUniqKeys[1].Columns.String(), "id,org_id") + test.S(t).ExpectEquals(sharedUniqKeys[2].Columns.String(), "id") }