Skip to content

Commit

Permalink
chore(schema): rename ReferenceType to ReferenceableType (#22698)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Dec 3, 2024
1 parent 9d9c19c commit 1c4dc89
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions schema/diff/field_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}

Expand All @@ -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.
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion schema/diff/field_diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func Test_compareField(t *testing.T) {
OldReferencedType: "old",
NewReferencedType: "new",
},
trueF: FieldDiff.ReferenceTypeChanged,
trueF: FieldDiff.ReferenceableTypeChanged,
},
}

Expand Down
4 changes: 2 additions & 2 deletions schema/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions schema/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1c4dc89

Please sign in to comment.