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
d86183b9
Commit
d86183b9
authored
1 year ago
by
Anton Sattarov
Browse files
Options
Downloads
Patches
Plain Diff
Добавлен поиск по идентификатору записи для случая когда не указано выражение для фильтрации
parent
30b5e866
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/expr/mongo.go
+6
-1
6 additions, 1 deletion
pkg/expr/mongo.go
pkg/expr/mongo_test.go
+2
-1
2 additions, 1 deletion
pkg/expr/mongo_test.go
with
8 additions
and
2 deletions
pkg/expr/mongo.go
+
6
−
1
View file @
d86183b9
...
@@ -62,7 +62,12 @@ func convertToMongo(ctx context.Context, tree *parser.Tree, env map[string]inter
...
@@ -62,7 +62,12 @@ func convertToMongo(ctx context.Context, tree *parser.Tree, env map[string]inter
case
bson
.
M
:
case
bson
.
M
:
b
=
e
b
=
e
case
string
:
case
string
:
b
=
bson
.
M
{
"$text"
:
bson
.
M
{
"$search"
:
e
}}
b
=
bson
.
M
{
"$or"
:
bson
.
A
{
bson
.
M
{
"_id"
:
e
},
bson
.
M
{
"$text"
:
bson
.
M
{
"$search"
:
e
}},
},
}
default
:
default
:
err
=
fmt
.
Errorf
(
"invalid expression"
)
err
=
fmt
.
Errorf
(
"invalid expression"
)
}
}
...
...
This diff is collapsed.
Click to expand it.
pkg/expr/mongo_test.go
+
2
−
1
View file @
d86183b9
...
@@ -50,6 +50,7 @@ func TestConvertToMongo(t *testing.T) {
...
@@ -50,6 +50,7 @@ func TestConvertToMongo(t *testing.T) {
{
"time"
,
fmt
.
Sprintf
(
"d > Time.Time('%s')"
,
now
.
Format
(
time
.
RFC3339
)),
nil
,
bson
.
M
{
"d"
:
bson
.
M
{
"$gt"
:
tm
}},
false
},
{
"time"
,
fmt
.
Sprintf
(
"d > Time.Time('%s')"
,
now
.
Format
(
time
.
RFC3339
)),
nil
,
bson
.
M
{
"d"
:
bson
.
M
{
"$gt"
:
tm
}},
false
},
{
"in"
,
"In(s, [1,2,3])"
,
nil
,
bson
.
M
{
"s"
:
bson
.
M
{
"$in"
:
[]
interface
{}{
1
,
2
,
3
}}},
false
},
{
"in"
,
"In(s, [1,2,3])"
,
nil
,
bson
.
M
{
"s"
:
bson
.
M
{
"$in"
:
[]
interface
{}{
1
,
2
,
3
}}},
false
},
{
"in"
,
"In(s, 1)"
,
nil
,
bson
.
M
{
"s"
:
bson
.
M
{
"$in"
:
[]
interface
{}{
1
}}},
false
},
{
"in"
,
"In(s, 1)"
,
nil
,
bson
.
M
{
"s"
:
bson
.
M
{
"$in"
:
[]
interface
{}{
1
}}},
false
},
{
"text search or id"
,
"id"
,
nil
,
bson
.
M
{
"$or"
:
bson
.
A
{
bson
.
M
{
"_id"
:
"id"
},
bson
.
M
{
"$text"
:
bson
.
M
{
"$search"
:
"id"
}}}},
false
},
}
}
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
...
@@ -72,7 +73,7 @@ func BenchmarkConvertToMongo(b *testing.B) {
...
@@ -72,7 +73,7 @@ func BenchmarkConvertToMongo(b *testing.B) {
//fmt.Println(len(exp))
//fmt.Println(len(exp))
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
ConvertToMongo
(
ctx
,
exp
,
nil
,
nil
,
expr
.
Patch
(
&
testVisitor
{}))
_
,
_
=
ConvertToMongo
(
ctx
,
exp
,
nil
,
nil
,
expr
.
Patch
(
&
testVisitor
{}))
}
}
}
}
...
...
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