Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Bryan Kaperick
jio
Commits
1ddd56e9
Commit
1ddd56e9
authored
Aug 17, 2017
by
preetwinder
Committed by
Vincent Bechu
Aug 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support mixed queries and add tests
/reviewed-on
nexedi/jio!63
parent
6c040d84
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
src/queries/query.js
src/queries/query.js
+1
-1
test/queries/tests.js
test/queries/tests.js
+36
-1
No files found.
src/queries/query.js
View file @
1ddd56e9
...
@@ -743,7 +743,7 @@
...
@@ -743,7 +743,7 @@
value
=
'
%
'
+
this
.
value
+
'
%
'
;
value
=
'
%
'
+
this
.
value
+
'
%
'
;
for
(
k
in
item
)
{
for
(
k
in
item
)
{
if
(
item
.
hasOwnProperty
(
k
))
{
if
(
item
.
hasOwnProperty
(
k
))
{
if
(
k
!==
'
__id
'
)
{
if
(
k
!==
'
__id
'
&&
item
[
k
]
)
{
if
(
matchMethod
(
item
[
k
],
value
)
===
true
)
{
if
(
matchMethod
(
item
[
k
],
value
)
===
true
)
{
return
true
;
return
true
;
}
}
...
...
test/queries/tests.js
View file @
1ddd56e9
...
@@ -440,7 +440,42 @@
...
@@ -440,7 +440,42 @@
});
});
});
});
// Asterisk wildcard is not supported yet.
// Test queries which have components with key and without it.
// Default operator used if not present is AND.
test
(
'
Mixed query
'
,
function
()
{
var
doc_list
=
[
{
"
identifier
"
:
"
a
"
,
"
value
"
:
"
test1
"
,
"
time
"
:
"
2016
"
},
{
"
identifier
"
:
"
b
"
,
"
value
"
:
"
test2
"
,
"
time
"
:
"
2017
"
},
{
"
identifier
"
:
"
c
"
,
"
value
"
:
"
test3
"
,
"
time
"
:
"
2017
"
}
];
stop
();
expect
(
2
);
jIO
.
QueryFactory
.
create
(
'
test2 time:%2017%
'
).
exec
(
doc_list
).
then
(
function
(
doc_list
)
{
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
b
"
,
"
value
"
:
"
test2
"
,
"
time
"
:
"
2017
"
}
],
'
Document with test2 in any column and 2017 in time is matched
'
);
doc_list
=
[
{
"
identifier
"
:
"
a
"
,
"
value
"
:
"
test post 1
"
,
"
time
"
:
"
2016
"
},
{
"
identifier
"
:
"
b
"
,
"
value
"
:
"
test post 2
"
,
"
time
"
:
"
2017
"
},
{
"
identifier
"
:
"
c
"
,
"
value
"
:
"
test post 3
"
,
"
time
"
:
"
2018
"
}
];
return
jIO
.
QueryFactory
.
create
(
'
value:"%test post 2%" OR c OR
'
+
'
2016
'
).
exec
(
doc_list
).
then
(
function
(
doc_list
)
{
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
a
"
,
"
value
"
:
"
test post 1
"
,
"
time
"
:
"
2016
"
},
{
"
identifier
"
:
"
b
"
,
"
value
"
:
"
test post 2
"
,
"
time
"
:
"
2017
"
},
{
"
identifier
"
:
"
c
"
,
"
value
"
:
"
test post 3
"
,
"
time
"
:
"
2018
"
}
],
'
Documents with "test post 2" in value or "c" or "2016"
'
+
'
anywhere are matched
'
);
}).
always
(
start
);
});
});
// Asterisk wildcard is not supported yet.
/* test('Full text query with asterisk', function () {
/* test('Full text query with asterisk', function () {
var doc_list = [
var doc_list = [
{"identifier": "abc"},
{"identifier": "abc"},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment