diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index bac95d05de2e863e5540c02f8553e431b2f602c7..6b26f3367a3774f9a29ae18b118cce2dd1a4bd89 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -2,6 +2,7 @@ package schema import ( "context" + "reflect" "git.perx.ru/perxis/perxis-go/pkg/errors" "git.perx.ru/perxis/perxis-go/pkg/expr" @@ -40,6 +41,16 @@ func (s *Schema) Clone(reset bool) *Schema { } } +func (s *Schema) Equal(sch *Schema) bool { + if s == sch { + return true + } + if s == nil || sch == nil { + return false + } + return reflect.DeepEqual(s.Field, sch.Field) +} + func (s Schema) WithIncludes(includes ...interface{}) *Schema { s.Field.SetIncludes(includes...) return &s diff --git a/pkg/setup/collection.go b/pkg/setup/collection.go index a42c650d67f0d9290490ca157b55fbcce6c8c344..725a04e390f3b298e612875378f33a62138cce3f 100644 --- a/pkg/setup/collection.go +++ b/pkg/setup/collection.go @@ -2,7 +2,6 @@ package setup import ( "context" - "reflect" "strings" "git.perx.ru/perxis/perxis-go/pkg/collections" @@ -53,7 +52,7 @@ func OverwriteCollection() CollectionsOption { update := new.Name != old.Name || new.IsSingle() != old.IsSingle() || new.IsSystem() != old.IsSystem() || new.IsNoData() != old.IsNoData() || new.Hidden != old.Hidden || new.IsView() != old.IsView() || !data.ElementsMatch(old.Tags, new.Tags) - return new, update, !reflect.DeepEqual(old.Schema, new.Schema), nil + return new, update, old.Schema.Equal(new.Schema), nil } } } @@ -91,7 +90,7 @@ func DefaultUpdateCollectionStrategyFn(_ *Setup, exist, collection *collections. update = update && *exist.View == *collection.View } - setSchema = !collection.IsView() && !reflect.DeepEqual(exist.Schema, collection.Schema) + setSchema = !collection.IsView() && !exist.Schema.Equal(collection.Schema) return collection, update, setSchema, nil }