Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
fix: use PropertySchemaID.Equal
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Aug 9, 2021
1 parent 41c3771 commit 1c3cf15
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/layer/infobox.go
Expand Up @@ -165,7 +165,7 @@ func (i *Infobox) ValidateProperties(pm property.Map) error {
if lp == nil {
return errors.New("property does not exist")
}
if lp.Schema() != builtin.PropertySchemaIDInfobox {
if !lp.Schema().Equal(builtin.PropertySchemaIDInfobox) {
return errors.New("property has a invalid schema")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/layer/infobox_field.go
Expand Up @@ -48,7 +48,7 @@ func (i *InfoboxField) ValidateProperty(pm property.Map) error {
if lp == nil {
return errors.New("property does not exist")
}
if lp.Schema() != id.MustPropertySchemaIDFromExtension(i.plugin, i.extension) {
if !lp.Schema().Equal(id.MustPropertySchemaIDFromExtension(i.plugin, i.extension)) {
return errors.New("property has a invalid schema")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/layer/layer.go
Expand Up @@ -211,7 +211,7 @@ func (l *layerBase) ValidateProperties(pm property.Map) error {
return errors.New("layer property does not exist")
}

if lp.Schema() != psid {
if !lp.Schema().Equal(psid) {
return errors.New("layer property has a invalid schema")
}
} else if l.plugin != nil || l.extension != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/property/builder.go
Expand Up @@ -33,7 +33,7 @@ func (b *Builder) Build() (*Property, error) {
return nil, ErrInvalidPropertySchemaID
}
for _, i := range b.p.items {
if i.Schema() != b.p.schema {
if !i.Schema().Equal(b.p.schema) {
return nil, ErrInvalidItem
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/property/group.go
Expand Up @@ -163,7 +163,7 @@ func (g *Group) MigrateSchema(ctx context.Context, newSchema *Schema, dl dataset

// GetOrCreateField _
func (g *Group) GetOrCreateField(ps *Schema, fid id.PropertySchemaFieldID) (*Field, bool) {
if g == nil || ps == nil || g.Schema() != ps.ID() {
if g == nil || ps == nil || !g.Schema().Equal(ps.ID()) {
return nil, false
}
psg := ps.Group(g.SchemaGroup())
Expand Down Expand Up @@ -249,7 +249,7 @@ func (g *Group) MigrateDataset(q DatasetMigrationParam) {
}

func (g *Group) UpdateNameFieldValue(ps *Schema, value *Value) error {
if g == nil || ps == nil || g.Schema() != ps.ID() {
if g == nil || ps == nil || !g.Schema().Equal(ps.ID()) {
return nil
}
if psg := ps.GroupByPointer(NewPointer(&g.itemBase.SchemaGroup, nil, nil)); psg != nil {
Expand All @@ -269,7 +269,7 @@ func (p *Group) ValidateSchema(ps *SchemaGroup) error {
if ps == nil {
return errors.New("invalid schema")
}
if p.Schema() != ps.Schema() {
if !p.Schema().Equal(ps.Schema()) {
return errors.New("invalid schema id")
}
if p.SchemaGroup() != ps.ID() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/property/group_list.go
Expand Up @@ -339,7 +339,7 @@ func (g *GroupList) GetOrCreateField(ps *Schema, ptr *Pointer) (*Field, bool) {

// CreateAndAddListItem _
func (g *GroupList) CreateAndAddListItem(ps *Schema, index *int) *Group {
if g == nil || ps == nil || g.Schema() != ps.ID() {
if g == nil || ps == nil || !g.Schema().Equal(ps.ID()) {
return nil
}
psg := ps.Group(g.SchemaGroup())
Expand Down Expand Up @@ -377,7 +377,7 @@ func (p *GroupList) ValidateSchema(ps *SchemaGroup) error {
if ps == nil {
return errors.New("invalid schema")
}
if p.Schema() != ps.Schema() {
if !p.Schema().Equal(ps.Schema()) {
return errors.New("invalid schema id")
}
if p.SchemaGroup() != ps.ID() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/property/merged.go
Expand Up @@ -109,7 +109,7 @@ func (f *MergedField) DatasetValue(ctx context.Context, d dataset.GraphLoader) (

// Merge merges two properties
func Merge(o *Property, p *Property, linked *id.DatasetID) *Merged {
if o == nil && p == nil || o != nil && p != nil && o.Schema() != p.Schema() {
if o == nil && p == nil || o != nil && p != nil && !o.Schema().Equal(p.Schema()) {
return nil
}

Expand Down

0 comments on commit 1c3cf15

Please sign in to comment.