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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
e09493c3
Commit
e09493c3
authored
1 year ago
by
Danis Kirasirov
Browse files
Options
Downloads
Patches
Plain Diff
add ExprMapper interface
parent
6c9d25ab
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/expr/expr.go
+9
-0
9 additions, 0 deletions
pkg/expr/expr.go
pkg/expr/mongo.go
+1
-1
1 addition, 1 deletion
pkg/expr/mongo.go
pkg/references/reference.go
+8
-1
8 additions, 1 deletion
pkg/references/reference.go
with
18 additions
and
2 deletions
pkg/expr/expr.go
+
9
−
0
View file @
e09493c3
...
@@ -31,6 +31,11 @@ func Eval(ctx context.Context, input string, env map[string]interface{}) (interf
...
@@ -31,6 +31,11 @@ func Eval(ctx context.Context, input string, env map[string]interface{}) (interf
}
}
for
k
,
v
:=
range
env
{
for
k
,
v
:=
range
env
{
if
mapper
,
ok
:=
v
.
(
ExprMapper
);
ok
{
e
[
k
]
=
mapper
.
ToExprMap
()
continue
}
e
[
k
]
=
v
e
[
k
]
=
v
}
}
...
@@ -79,3 +84,7 @@ func IsExpression(input string) bool {
...
@@ -79,3 +84,7 @@ func IsExpression(input string) bool {
return
false
return
false
}
}
type
ExprMapper
interface
{
ToExprMap
()
map
[
string
]
interface
{}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pkg/expr/mongo.go
+
1
−
1
View file @
e09493c3
...
@@ -213,7 +213,7 @@ func (c *compiler) UnaryNode(node *ast.UnaryNode) interface{} {
...
@@ -213,7 +213,7 @@ func (c *compiler) UnaryNode(node *ast.UnaryNode) interface{} {
return
bson
.
M
{
c
.
identifier
(
nodeIn
.
Left
)
:
bson
.
M
{
"$nin"
:
c
.
eval
(
nodeIn
.
Right
)}}
return
bson
.
M
{
c
.
identifier
(
nodeIn
.
Left
)
:
bson
.
M
{
"$nin"
:
c
.
eval
(
nodeIn
.
Right
)}}
}
}
return
bson
.
M
{
"$not"
:
c
.
compile
(
node
.
Node
)}
return
bson
.
M
{
"$not"
:
c
.
compile
(
node
.
Node
)}
default
:
default
:
panic
(
fmt
.
Sprintf
(
"unknown operator (%v)"
,
node
.
Operator
))
panic
(
fmt
.
Sprintf
(
"unknown operator (%v)"
,
node
.
Operator
))
}
}
...
...
This diff is collapsed.
Click to expand it.
pkg/references/reference.go
+
8
−
1
View file @
e09493c3
...
@@ -25,6 +25,13 @@ func (r *Reference) MarshalBSON() ([]byte, error) {
...
@@ -25,6 +25,13 @@ func (r *Reference) MarshalBSON() ([]byte, error) {
return
bson
.
Marshal
(
d
)
return
bson
.
Marshal
(
d
)
}
}
func
(
r
*
Reference
)
ToExprMap
()
map
[
string
]
interface
{}
{
return
map
[
string
]
interface
{}{
"collection_id"
:
r
.
CollectionID
,
"id"
:
r
.
ID
,
}
}
func
ReferenceFromPB
(
refPB
*
pb
.
Reference
)
*
Reference
{
func
ReferenceFromPB
(
refPB
*
pb
.
Reference
)
*
Reference
{
if
refPB
==
nil
{
if
refPB
==
nil
{
return
nil
return
nil
...
@@ -107,4 +114,4 @@ func EqualArrays(sr1, sr2 []*Reference) bool {
...
@@ -107,4 +114,4 @@ func EqualArrays(sr1, sr2 []*Reference) bool {
func
(
r
*
Reference
)
IsValid
()
bool
{
func
(
r
*
Reference
)
IsValid
()
bool
{
return
r
!=
nil
&&
r
.
ID
!=
""
&&
r
.
CollectionID
!=
""
&&
!
r
.
Disabled
return
r
!=
nil
&&
r
.
ID
!=
""
&&
r
.
CollectionID
!=
""
&&
!
r
.
Disabled
}
}
\ No newline at end of file
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