Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
d310b808
Commit
d310b808
authored
1 year ago
by
Alena Petraki
Browse files
Options
Downloads
Patches
Plain Diff
Добавлена функция для сравнения схем
parent
08b8edf5
Branches
docs/PRXS-2511-SyncFieldPolicy
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/schema/schema.go
+11
-0
11 additions, 0 deletions
pkg/schema/schema.go
pkg/setup/collection.go
+2
-3
2 additions, 3 deletions
pkg/setup/collection.go
with
13 additions
and
3 deletions
pkg/schema/schema.go
+
11
−
0
View file @
d310b808
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
pkg/setup/collection.go
+
2
−
3
View file @
d310b808
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment