refactor(schema)!: rename ObjectType -> StateObjectType (#21691)
Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com>
This commit is contained in:
co-authored by
cool-developer
parent
397ff0bd22
commit
ae40e809b9
+18
-18
@@ -4,14 +4,14 @@ import "cosmossdk.io/schema"
|
||||
|
||||
// ModuleSchemaDiff represents the difference between two module schemas.
|
||||
type ModuleSchemaDiff struct {
|
||||
// AddedObjectTypes is a list of object types that were added.
|
||||
AddedObjectTypes []schema.ObjectType
|
||||
// AddedStateObjectTypes is a list of object types that were added.
|
||||
AddedStateObjectTypes []schema.StateObjectType
|
||||
|
||||
// ChangedObjectTypes is a list of object types that were changed.
|
||||
ChangedObjectTypes []ObjectTypeDiff
|
||||
// ChangedStateObjectTypes is a list of object types that were changed.
|
||||
ChangedStateObjectTypes []StateObjectTypeDiff
|
||||
|
||||
// RemovedObjectTypes is a list of object types that were removed.
|
||||
RemovedObjectTypes []schema.ObjectType
|
||||
// RemovedStateObjectTypes is a list of object types that were removed.
|
||||
RemovedStateObjectTypes []schema.StateObjectType
|
||||
|
||||
// AddedEnumTypes is a list of enum types that were added.
|
||||
AddedEnumTypes []schema.EnumType
|
||||
@@ -41,23 +41,23 @@ type ModuleSchemaDiff struct {
|
||||
func CompareModuleSchemas(oldSchema, newSchema schema.ModuleSchema) ModuleSchemaDiff {
|
||||
diff := ModuleSchemaDiff{}
|
||||
|
||||
oldSchema.ObjectTypes(func(oldObj schema.ObjectType) bool {
|
||||
newObj, found := newSchema.LookupObjectType(oldObj.Name)
|
||||
oldSchema.StateObjectTypes(func(oldObj schema.StateObjectType) bool {
|
||||
newObj, found := newSchema.LookupStateObjectType(oldObj.Name)
|
||||
if !found {
|
||||
diff.RemovedObjectTypes = append(diff.RemovedObjectTypes, oldObj)
|
||||
diff.RemovedStateObjectTypes = append(diff.RemovedStateObjectTypes, oldObj)
|
||||
return true
|
||||
}
|
||||
objDiff := compareObjectType(oldObj, newObj)
|
||||
if !objDiff.Empty() {
|
||||
diff.ChangedObjectTypes = append(diff.ChangedObjectTypes, objDiff)
|
||||
diff.ChangedStateObjectTypes = append(diff.ChangedStateObjectTypes, objDiff)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
newSchema.ObjectTypes(func(newObj schema.ObjectType) bool {
|
||||
_, found := oldSchema.LookupObjectType(newObj.TypeName())
|
||||
newSchema.StateObjectTypes(func(newObj schema.StateObjectType) bool {
|
||||
_, found := oldSchema.LookupStateObjectType(newObj.TypeName())
|
||||
if !found {
|
||||
diff.AddedObjectTypes = append(diff.AddedObjectTypes, newObj)
|
||||
diff.AddedStateObjectTypes = append(diff.AddedStateObjectTypes, newObj)
|
||||
}
|
||||
return true
|
||||
})
|
||||
@@ -87,9 +87,9 @@ func CompareModuleSchemas(oldSchema, newSchema schema.ModuleSchema) ModuleSchema
|
||||
}
|
||||
|
||||
func (m ModuleSchemaDiff) Empty() bool {
|
||||
return len(m.AddedObjectTypes) == 0 &&
|
||||
len(m.ChangedObjectTypes) == 0 &&
|
||||
len(m.RemovedObjectTypes) == 0 &&
|
||||
return len(m.AddedStateObjectTypes) == 0 &&
|
||||
len(m.ChangedStateObjectTypes) == 0 &&
|
||||
len(m.RemovedStateObjectTypes) == 0 &&
|
||||
len(m.AddedEnumTypes) == 0 &&
|
||||
len(m.ChangedEnumTypes) == 0 &&
|
||||
len(m.RemovedEnumTypes) == 0
|
||||
@@ -102,11 +102,11 @@ func (m ModuleSchemaDiff) Empty() bool {
|
||||
func (m ModuleSchemaDiff) HasCompatibleChanges() bool {
|
||||
// object and enum types can be added but not removed
|
||||
// changed object and enum types must have compatible changes
|
||||
if len(m.RemovedObjectTypes) != 0 || len(m.RemovedEnumTypes) != 0 {
|
||||
if len(m.RemovedStateObjectTypes) != 0 || len(m.RemovedEnumTypes) != 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, objectType := range m.ChangedObjectTypes {
|
||||
for _, objectType := range m.ChangedStateObjectTypes {
|
||||
if !objectType.HasCompatibleChanges() {
|
||||
return false
|
||||
}
|
||||
|
||||
+28
-28
@@ -18,11 +18,11 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "no change",
|
||||
oldSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
oldSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
}),
|
||||
newSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
newSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
}),
|
||||
@@ -33,12 +33,12 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
{
|
||||
name: "object type added",
|
||||
oldSchema: requireModuleSchema(t),
|
||||
newSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
newSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
}),
|
||||
diff: ModuleSchemaDiff{
|
||||
AddedObjectTypes: []schema.ObjectType{
|
||||
AddedStateObjectTypes: []schema.StateObjectType{
|
||||
{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
@@ -49,13 +49,13 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "object type removed",
|
||||
oldSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
oldSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
}),
|
||||
newSchema: requireModuleSchema(t),
|
||||
diff: ModuleSchemaDiff{
|
||||
RemovedObjectTypes: []schema.ObjectType{
|
||||
RemovedStateObjectTypes: []schema.StateObjectType{
|
||||
{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
@@ -66,16 +66,16 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "object type changed, key field added",
|
||||
oldSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
oldSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
}),
|
||||
newSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
newSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}, {Name: "key2", Kind: schema.StringKind}},
|
||||
}),
|
||||
diff: ModuleSchemaDiff{
|
||||
ChangedObjectTypes: []ObjectTypeDiff{
|
||||
ChangedStateObjectTypes: []StateObjectTypeDiff{
|
||||
{
|
||||
Name: "object1",
|
||||
KeyFieldsDiff: FieldsDiff{
|
||||
@@ -90,17 +90,17 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "object type changed, nullable value field added",
|
||||
oldSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
oldSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
}),
|
||||
newSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
newSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
ValueFields: []schema.Field{{Name: "value1", Kind: schema.StringKind, Nullable: true}},
|
||||
}),
|
||||
diff: ModuleSchemaDiff{
|
||||
ChangedObjectTypes: []ObjectTypeDiff{
|
||||
ChangedStateObjectTypes: []StateObjectTypeDiff{
|
||||
{
|
||||
Name: "object1",
|
||||
ValueFieldsDiff: FieldsDiff{
|
||||
@@ -113,17 +113,17 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "object type changed, non-nullable value field added",
|
||||
oldSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
oldSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
}),
|
||||
newSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
newSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}},
|
||||
ValueFields: []schema.Field{{Name: "value1", Kind: schema.StringKind}},
|
||||
}),
|
||||
diff: ModuleSchemaDiff{
|
||||
ChangedObjectTypes: []ObjectTypeDiff{
|
||||
ChangedStateObjectTypes: []StateObjectTypeDiff{
|
||||
{
|
||||
Name: "object1",
|
||||
ValueFieldsDiff: FieldsDiff{
|
||||
@@ -136,16 +136,16 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "object type changed, fields reordered",
|
||||
oldSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
oldSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.StringKind}, {Name: "key2", Kind: schema.StringKind}},
|
||||
}),
|
||||
newSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
newSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key2", Kind: schema.StringKind}, {Name: "key1", Kind: schema.StringKind}},
|
||||
}),
|
||||
diff: ModuleSchemaDiff{
|
||||
ChangedObjectTypes: []ObjectTypeDiff{
|
||||
ChangedStateObjectTypes: []StateObjectTypeDiff{
|
||||
{
|
||||
Name: "object1",
|
||||
KeyFieldsDiff: FieldsDiff{
|
||||
@@ -159,11 +159,11 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "enum type added, nullable value field added",
|
||||
oldSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
oldSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.Int32Kind}},
|
||||
}),
|
||||
newSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
newSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.Int32Kind}},
|
||||
ValueFields: []schema.Field{
|
||||
@@ -177,7 +177,7 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
},
|
||||
schema.EnumType{Name: "enum1", Values: []schema.EnumValueDefinition{{Name: "a", Value: 1}, {Name: "b", Value: 2}}}),
|
||||
diff: ModuleSchemaDiff{
|
||||
ChangedObjectTypes: []ObjectTypeDiff{
|
||||
ChangedStateObjectTypes: []StateObjectTypeDiff{
|
||||
{
|
||||
Name: "object1",
|
||||
ValueFieldsDiff: FieldsDiff{
|
||||
@@ -201,7 +201,7 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
{
|
||||
name: "enum type removed",
|
||||
oldSchema: requireModuleSchema(t,
|
||||
schema.ObjectType{
|
||||
schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.Int32Kind}},
|
||||
ValueFields: []schema.Field{
|
||||
@@ -213,12 +213,12 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
},
|
||||
},
|
||||
schema.EnumType{Name: "enum1", Values: []schema.EnumValueDefinition{{Name: "a", Value: 1}, {Name: "b", Value: 2}}}),
|
||||
newSchema: requireModuleSchema(t, schema.ObjectType{
|
||||
newSchema: requireModuleSchema(t, schema.StateObjectType{
|
||||
Name: "object1",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.Int32Kind}},
|
||||
}),
|
||||
diff: ModuleSchemaDiff{
|
||||
ChangedObjectTypes: []ObjectTypeDiff{
|
||||
ChangedStateObjectTypes: []StateObjectTypeDiff{
|
||||
{
|
||||
Name: "object1",
|
||||
ValueFieldsDiff: FieldsDiff{
|
||||
@@ -277,27 +277,27 @@ func TestCompareModuleSchemas(t *testing.T) {
|
||||
{
|
||||
name: "object type and enum type name switched",
|
||||
oldSchema: requireModuleSchema(t,
|
||||
schema.ObjectType{
|
||||
schema.StateObjectType{
|
||||
Name: "foo",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.EnumKind, ReferencedType: "bar"}},
|
||||
},
|
||||
schema.EnumType{Name: "bar", Values: []schema.EnumValueDefinition{{Name: "a", Value: 1}}},
|
||||
),
|
||||
newSchema: requireModuleSchema(t,
|
||||
schema.ObjectType{
|
||||
schema.StateObjectType{
|
||||
Name: "bar",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.EnumKind, ReferencedType: "foo"}},
|
||||
},
|
||||
schema.EnumType{Name: "foo", Values: []schema.EnumValueDefinition{{Name: "a", Value: 1}}},
|
||||
),
|
||||
diff: ModuleSchemaDiff{
|
||||
RemovedObjectTypes: []schema.ObjectType{
|
||||
RemovedStateObjectTypes: []schema.StateObjectType{
|
||||
{
|
||||
Name: "foo",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.EnumKind, ReferencedType: "bar"}},
|
||||
},
|
||||
},
|
||||
AddedObjectTypes: []schema.ObjectType{
|
||||
AddedStateObjectTypes: []schema.StateObjectType{
|
||||
{
|
||||
Name: "bar",
|
||||
KeyFields: []schema.Field{{Name: "key1", Kind: schema.EnumKind, ReferencedType: "foo"}},
|
||||
|
||||
@@ -2,10 +2,10 @@ package diff
|
||||
|
||||
import "cosmossdk.io/schema"
|
||||
|
||||
// ObjectTypeDiff represents the difference between two object types.
|
||||
// StateObjectTypeDiff represents the difference between two object types.
|
||||
// The Empty method of KeyFieldsDiff and ValueFieldsDiff can be used to determine
|
||||
// if there were any changes to the key fields or value fields.
|
||||
type ObjectTypeDiff struct {
|
||||
type StateObjectTypeDiff struct {
|
||||
// Name is the name of the object type.
|
||||
Name string
|
||||
|
||||
@@ -39,8 +39,8 @@ type FieldsDiff struct {
|
||||
NewOrder []string
|
||||
}
|
||||
|
||||
func compareObjectType(oldObj, newObj schema.ObjectType) ObjectTypeDiff {
|
||||
diff := ObjectTypeDiff{
|
||||
func compareObjectType(oldObj, newObj schema.StateObjectType) StateObjectTypeDiff {
|
||||
diff := StateObjectTypeDiff{
|
||||
Name: oldObj.TypeName(),
|
||||
}
|
||||
|
||||
@@ -101,13 +101,13 @@ func compareFields(oldFields, newFields []schema.Field) FieldsDiff {
|
||||
}
|
||||
|
||||
// Empty returns true if the object type diff has no changes.
|
||||
func (o ObjectTypeDiff) Empty() bool {
|
||||
func (o StateObjectTypeDiff) Empty() bool {
|
||||
return o.KeyFieldsDiff.Empty() && o.ValueFieldsDiff.Empty()
|
||||
}
|
||||
|
||||
// HasCompatibleChanges returns true if the diff contains only compatible changes.
|
||||
// The only supported compatible change is adding nullable value fields.
|
||||
func (o ObjectTypeDiff) HasCompatibleChanges() bool {
|
||||
func (o StateObjectTypeDiff) HasCompatibleChanges() bool {
|
||||
if !o.KeyFieldsDiff.Empty() {
|
||||
return false
|
||||
}
|
||||
@@ -10,33 +10,33 @@ import (
|
||||
func Test_objectTypeDiff(t *testing.T) {
|
||||
tt := []struct {
|
||||
name string
|
||||
oldType schema.ObjectType
|
||||
newType schema.ObjectType
|
||||
diff ObjectTypeDiff
|
||||
trueF func(ObjectTypeDiff) bool
|
||||
oldType schema.StateObjectType
|
||||
newType schema.StateObjectType
|
||||
diff StateObjectTypeDiff
|
||||
trueF func(StateObjectTypeDiff) bool
|
||||
hasCompatibleChanges bool
|
||||
}{
|
||||
{
|
||||
name: "no change",
|
||||
oldType: schema.ObjectType{
|
||||
oldType: schema.StateObjectType{
|
||||
KeyFields: []schema.Field{{Name: "id", Kind: schema.Int32Kind}},
|
||||
},
|
||||
newType: schema.ObjectType{
|
||||
newType: schema.StateObjectType{
|
||||
KeyFields: []schema.Field{{Name: "id", Kind: schema.Int32Kind}},
|
||||
},
|
||||
diff: ObjectTypeDiff{},
|
||||
trueF: ObjectTypeDiff.Empty,
|
||||
diff: StateObjectTypeDiff{},
|
||||
trueF: StateObjectTypeDiff.Empty,
|
||||
hasCompatibleChanges: true,
|
||||
},
|
||||
{
|
||||
name: "key fields changed",
|
||||
oldType: schema.ObjectType{
|
||||
oldType: schema.StateObjectType{
|
||||
KeyFields: []schema.Field{{Name: "id", Kind: schema.Int32Kind}},
|
||||
},
|
||||
newType: schema.ObjectType{
|
||||
newType: schema.StateObjectType{
|
||||
KeyFields: []schema.Field{{Name: "id", Kind: schema.StringKind}},
|
||||
},
|
||||
diff: ObjectTypeDiff{
|
||||
diff: StateObjectTypeDiff{
|
||||
KeyFieldsDiff: FieldsDiff{
|
||||
Changed: []FieldDiff{
|
||||
{
|
||||
@@ -47,18 +47,18 @@ func Test_objectTypeDiff(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
trueF: func(d ObjectTypeDiff) bool { return !d.KeyFieldsDiff.Empty() },
|
||||
trueF: func(d StateObjectTypeDiff) bool { return !d.KeyFieldsDiff.Empty() },
|
||||
hasCompatibleChanges: false,
|
||||
},
|
||||
{
|
||||
name: "value fields changed",
|
||||
oldType: schema.ObjectType{
|
||||
oldType: schema.StateObjectType{
|
||||
ValueFields: []schema.Field{{Name: "name", Kind: schema.StringKind}},
|
||||
},
|
||||
newType: schema.ObjectType{
|
||||
newType: schema.StateObjectType{
|
||||
ValueFields: []schema.Field{{Name: "name", Kind: schema.Int32Kind}},
|
||||
},
|
||||
diff: ObjectTypeDiff{
|
||||
diff: StateObjectTypeDiff{
|
||||
ValueFieldsDiff: FieldsDiff{
|
||||
Changed: []FieldDiff{
|
||||
{
|
||||
@@ -69,52 +69,52 @@ func Test_objectTypeDiff(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
trueF: func(d ObjectTypeDiff) bool { return !d.ValueFieldsDiff.Empty() },
|
||||
trueF: func(d StateObjectTypeDiff) bool { return !d.ValueFieldsDiff.Empty() },
|
||||
hasCompatibleChanges: false,
|
||||
},
|
||||
{
|
||||
name: "nullable value field added",
|
||||
oldType: schema.ObjectType{
|
||||
oldType: schema.StateObjectType{
|
||||
ValueFields: []schema.Field{{Name: "id", Kind: schema.Int32Kind}},
|
||||
},
|
||||
newType: schema.ObjectType{
|
||||
newType: schema.StateObjectType{
|
||||
ValueFields: []schema.Field{{Name: "id", Kind: schema.Int32Kind}, {Name: "name", Kind: schema.StringKind, Nullable: true}},
|
||||
},
|
||||
diff: ObjectTypeDiff{
|
||||
diff: StateObjectTypeDiff{
|
||||
ValueFieldsDiff: FieldsDiff{
|
||||
Added: []schema.Field{{Name: "name", Kind: schema.StringKind, Nullable: true}},
|
||||
},
|
||||
},
|
||||
trueF: func(d ObjectTypeDiff) bool { return !d.ValueFieldsDiff.Empty() },
|
||||
trueF: func(d StateObjectTypeDiff) bool { return !d.ValueFieldsDiff.Empty() },
|
||||
hasCompatibleChanges: true,
|
||||
},
|
||||
{
|
||||
name: "non-nullable value field added",
|
||||
oldType: schema.ObjectType{
|
||||
oldType: schema.StateObjectType{
|
||||
ValueFields: []schema.Field{{Name: "id", Kind: schema.Int32Kind}},
|
||||
},
|
||||
newType: schema.ObjectType{
|
||||
newType: schema.StateObjectType{
|
||||
ValueFields: []schema.Field{{Name: "id", Kind: schema.Int32Kind}, {Name: "name", Kind: schema.StringKind}},
|
||||
},
|
||||
diff: ObjectTypeDiff{
|
||||
diff: StateObjectTypeDiff{
|
||||
ValueFieldsDiff: FieldsDiff{
|
||||
Added: []schema.Field{{Name: "name", Kind: schema.StringKind}},
|
||||
},
|
||||
},
|
||||
trueF: func(d ObjectTypeDiff) bool { return !d.ValueFieldsDiff.Empty() },
|
||||
trueF: func(d StateObjectTypeDiff) bool { return !d.ValueFieldsDiff.Empty() },
|
||||
hasCompatibleChanges: false,
|
||||
},
|
||||
{
|
||||
name: "fields reordered",
|
||||
oldType: schema.ObjectType{
|
||||
oldType: schema.StateObjectType{
|
||||
KeyFields: []schema.Field{{Name: "id", Kind: schema.Int32Kind}, {Name: "name", Kind: schema.StringKind}},
|
||||
ValueFields: []schema.Field{{Name: "x", Kind: schema.Int32Kind}, {Name: "y", Kind: schema.StringKind}},
|
||||
},
|
||||
newType: schema.ObjectType{
|
||||
newType: schema.StateObjectType{
|
||||
KeyFields: []schema.Field{{Name: "name", Kind: schema.StringKind}, {Name: "id", Kind: schema.Int32Kind}},
|
||||
ValueFields: []schema.Field{{Name: "y", Kind: schema.StringKind}, {Name: "x", Kind: schema.Int32Kind}},
|
||||
},
|
||||
diff: ObjectTypeDiff{
|
||||
diff: StateObjectTypeDiff{
|
||||
KeyFieldsDiff: FieldsDiff{
|
||||
OldOrder: []string{"id", "name"},
|
||||
NewOrder: []string{"name", "id"},
|
||||
@@ -124,7 +124,7 @@ func Test_objectTypeDiff(t *testing.T) {
|
||||
NewOrder: []string{"y", "x"},
|
||||
},
|
||||
},
|
||||
trueF: func(d ObjectTypeDiff) bool { return !d.KeyFieldsDiff.Empty() && !d.ValueFieldsDiff.Empty() },
|
||||
trueF: func(d StateObjectTypeDiff) bool { return !d.KeyFieldsDiff.Empty() && !d.ValueFieldsDiff.Empty() },
|
||||
hasCompatibleChanges: false,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user