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
Guillaume Royer
jio
Commits
a935229f
Commit
a935229f
authored
Dec 31, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed grammar for !=, don't throw exception in case of malformed query string, added tests
parent
1d22cda3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
5 deletions
+53
-5
docs/complex_queries.rst
docs/complex_queries.rst
+2
-2
src/queries/core/parser.par
src/queries/core/parser.par
+2
-2
src/queries/core/simplequery.js
src/queries/core/simplequery.js
+12
-0
test/queries/key-jiodate.tests.js
test/queries/key-jiodate.tests.js
+37
-1
No files found.
docs/complex_queries.rst
View file @
a935229f
...
...
@@ -344,9 +344,9 @@ Below you can find schemas for constructing queries.
OR -> /OR[ ]/
AND -> /AND[ ]/
NOT -> /NOT[ ]/
COLUMN -> /[^><= :\(\)"][^ :\(\)"]*:/
COLUMN -> /[^><
!
= :\(\)"][^ :\(\)"]*:/
STRING -> /"(\\.|[^\\"])*"/
WORD -> /[^><= :\(\)"][^ :\(\)"]*/
WORD -> /[^><
!
= :\(\)"][^ :\(\)"]*/
OPERATOR -> /(>=?|<=?|!?=)/
LEFT_PARENTHESE -> /\(/
RIGHT_PARENTHESE -> /\)/
...
...
src/queries/core/parser.par
View file @
a935229f
...
...
@@ -8,9 +8,9 @@
'AND' AND ;
'OR' OR ;
'NOT' NOT ;
'[^><= :\(\)"][^ :\(\)"]*:' COLUMN ;
'[^><
!
= :\(\)"][^ :\(\)"]*:' COLUMN ;
'"(\\.|[^\\"])*"' STRING ;
'[^><= :\(\)"][^ :\(\)"]*' WORD ;
'[^><
!
= :\(\)"][^ :\(\)"]*' WORD ;
'(>=?|<=?|!?=)' OPERATOR ;
##
...
...
src/queries/core/simplequery.js
View file @
a935229f
...
...
@@ -280,6 +280,9 @@ SimpleQuery.prototype["<"] = function (object_value, comparison_value) {
if
(
typeof
value
===
'
object
'
&&
value
.
hasOwnProperty
(
'
content
'
))
{
value
=
value
.
content
;
}
if
(
value
===
undefined
||
comparison_value
===
undefined
)
{
return
false
;
}
if
(
value
.
cmp
!==
undefined
)
{
return
value
.
cmp
(
comparison_value
)
<
0
;
}
...
...
@@ -304,6 +307,9 @@ SimpleQuery.prototype["<="] = function (object_value, comparison_value) {
if
(
typeof
value
===
'
object
'
&&
value
.
hasOwnProperty
(
'
content
'
))
{
value
=
value
.
content
;
}
if
(
value
===
undefined
||
comparison_value
===
undefined
)
{
return
false
;
}
if
(
value
.
cmp
!==
undefined
)
{
return
value
.
cmp
(
comparison_value
)
<=
0
;
}
...
...
@@ -328,6 +334,9 @@ SimpleQuery.prototype[">"] = function (object_value, comparison_value) {
if
(
typeof
value
===
'
object
'
&&
value
.
hasOwnProperty
(
'
content
'
))
{
value
=
value
.
content
;
}
if
(
value
===
undefined
||
comparison_value
===
undefined
)
{
return
false
;
}
if
(
value
.
cmp
!==
undefined
)
{
return
value
.
cmp
(
comparison_value
)
>
0
;
}
...
...
@@ -352,6 +361,9 @@ SimpleQuery.prototype[">="] = function (object_value, comparison_value) {
if
(
typeof
value
===
'
object
'
&&
value
.
hasOwnProperty
(
'
content
'
))
{
value
=
value
.
content
;
}
if
(
value
===
undefined
||
comparison_value
===
undefined
)
{
return
false
;
}
if
(
value
.
cmp
!==
undefined
)
{
return
value
.
cmp
(
comparison_value
)
>=
0
;
}
...
...
test/queries/key-jiodate.tests.js
View file @
a935229f
...
...
@@ -31,7 +31,7 @@
cast_to
:
jiodate
.
JIODate
}
}
};
}
,
query_list
=
null
;
doc_list
=
docList
();
complex_queries
.
QueryFactory
.
create
({
...
...
@@ -101,6 +101,42 @@
{
'
date
'
:
'
2012-03-04T08:52:13.746Z
'
,
'
identifier
'
:
'
twenty twelve
'
}
],
'
Match with "date >= 2011" (query tree form)
'
);
query_list
=
[
[
'
date: < "2011" OR date: "2012-03"
'
,
[
{
'
date
'
:
'
2010-03-04T08:52:13.746Z
'
,
'
identifier
'
:
'
twenty ten
'
},
{
'
date
'
:
'
2012-03-04T08:52:13.746Z
'
,
'
identifier
'
:
'
twenty twelve
'
}
]
],
[
'
date: >= "2011-01" AND date: != "2012-03-04T08:52:13.746Z"
'
,
[
{
'
date
'
:
'
2011-03-04T08:52:13.746Z
'
,
'
identifier
'
:
'
twenty eleven
'
}
]
]
];
query_list
.
forEach
(
function
(
o
)
{
var
qs
=
o
[
0
],
expected
=
o
[
1
];
doc_list
=
docList
();
complex_queries
.
QueryFactory
.
create
(
qs
,
key_schema
).
exec
(
doc_list
);
deepEqual
(
doc_list
,
expected
,
"
Match with '
"
+
qs
+
"
' (parsed query string)
"
);
});
query_list
=
[
'
date < "2011"
'
,
'
date <= "2011"
'
,
'
date > "2011"
'
,
'
date >= "2011"
'
];
query_list
.
forEach
(
function
(
qs
)
{
doc_list
=
docList
();
complex_queries
.
QueryFactory
.
create
(
qs
,
key_schema
).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
],
"
Match with an invalid parsed string
"
+
qs
+
"
should return empty list but not raise errors
"
);
});
});
...
...
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