From 1c4dc89ead78bf749818e84318c0529354d9964a Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 3 Dec 2024 09:07:32 +0100 Subject: [PATCH] chore(schema): rename `ReferenceType` to `ReferenceableType` (#22698) --- schema/diff/field_diff.go | 12 ++++++------ schema/diff/field_diff_test.go | 2 +- schema/enum.go | 4 ++-- schema/type.go | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/schema/diff/field_diff.go b/schema/diff/field_diff.go index ffc6c71ed1..8b2aaacaa1 100644 --- a/schema/diff/field_diff.go +++ b/schema/diff/field_diff.go @@ -3,7 +3,7 @@ package diff import "cosmossdk.io/schema" // FieldDiff represents the difference between two fields. -// The KindChanged, NullableChanged, and ReferenceTypeChanged methods can be used to determine +// The KindChanged, NullableChanged, and ReferenceableTypeChanged methods can be used to determine // what specific changes were made to the field. type FieldDiff struct { // Name is the name of the field. @@ -22,11 +22,11 @@ type FieldDiff struct { NewNullable bool // OldReferencedType is the name of the old referenced type. - // It will be empty if the field is not a reference type or if there was no change. + // It will be empty if the field is not a referenceable type or if there was no change. OldReferencedType string // NewReferencedType is the name of the new referenced type. - // It will be empty if the field is not a reference type or if there was no change. + // It will be empty if the field is not a referenceable type or if there was no change. NewReferencedType string } @@ -52,7 +52,7 @@ func compareField(oldField, newField schema.Field) FieldDiff { // Empty returns true if the field diff has no changes. func (d FieldDiff) Empty() bool { - return !d.KindChanged() && !d.NullableChanged() && !d.ReferenceTypeChanged() + return !d.KindChanged() && !d.NullableChanged() && !d.ReferenceableTypeChanged() } // KindChanged returns true if the field kind changed. @@ -65,7 +65,7 @@ func (d FieldDiff) NullableChanged() bool { return d.OldNullable != d.NewNullable } -// ReferenceTypeChanged returns true if the referenced type changed. -func (d FieldDiff) ReferenceTypeChanged() bool { +// ReferenceableTypeChanged returns true if the referenced type changed. +func (d FieldDiff) ReferenceableTypeChanged() bool { return d.OldReferencedType != d.NewReferencedType } diff --git a/schema/diff/field_diff_test.go b/schema/diff/field_diff_test.go index d584aae5a4..925673820b 100644 --- a/schema/diff/field_diff_test.go +++ b/schema/diff/field_diff_test.go @@ -45,7 +45,7 @@ func Test_compareField(t *testing.T) { OldReferencedType: "old", NewReferencedType: "new", }, - trueF: FieldDiff.ReferenceTypeChanged, + trueF: FieldDiff.ReferenceableTypeChanged, }, } diff --git a/schema/enum.go b/schema/enum.go index b52b01e1a5..c802eac875 100644 --- a/schema/enum.go +++ b/schema/enum.go @@ -41,8 +41,8 @@ func (e EnumType) TypeName() string { return e.Name } -func (EnumType) isType() {} -func (EnumType) isReferenceType() {} +func (EnumType) isType() {} +func (EnumType) isReferenceableType() {} // Validate validates the enum definition. func (e EnumType) Validate(TypeSet) error { diff --git a/schema/type.go b/schema/type.go index dfbc839ae0..bb02ea329e 100644 --- a/schema/type.go +++ b/schema/type.go @@ -13,13 +13,13 @@ type Type interface { isType() } -// ReferenceType is a marker interface that all types that can be the target of Field.ReferencedType implement. +// ReferenceableType is a marker interface that all types that can be the target of Field.ReferencedType implement. // Currently, this is only EnumType. -type ReferenceType interface { +type ReferenceableType interface { Type // isReferenceType is implemented if this is a reference type. - isReferenceType() + isReferenceableType() } // TypeSet represents something that has types and allows them to be looked up by name.