Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
lucas.parsy
jio
Commits
aae4a9af
Commit
aae4a9af
authored
Mar 10, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Query create(create(...)) bug fixed
parent
e2fee8eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
+41
-4
src/queries/core/complexquery.js
src/queries/core/complexquery.js
+17
-4
src/queries/core/simplequery.js
src/queries/core/simplequery.js
+1
-0
test/queries/tests.js
test/queries/tests.js
+23
-0
No files found.
src/queries/core/complexquery.js
View file @
aae4a9af
...
...
@@ -24,7 +24,7 @@ function ComplexQuery(spec, key_schema) {
* @default "AND"
* @optional
*/
this
.
operator
=
spec
.
operator
||
"
AND
"
;
this
.
operator
=
spec
.
operator
;
/**
* The sub Query list which are used to query an item.
...
...
@@ -45,6 +45,9 @@ function ComplexQuery(spec, key_schema) {
}
inherits
(
ComplexQuery
,
Query
);
ComplexQuery
.
prototype
.
operator
=
"
AND
"
;
ComplexQuery
.
prototype
.
type
=
"
complex
"
;
/**
* #crossLink "Query/match:method"
*/
...
...
@@ -60,12 +63,20 @@ ComplexQuery.prototype.match = function (item) {
* #crossLink "Query/toString:method"
*/
ComplexQuery
.
prototype
.
toString
=
function
()
{
var
str_list
=
[
"
(
"
],
this_operator
=
this
.
operator
;
var
str_list
=
[],
this_operator
=
this
.
operator
;
if
(
this
.
operator
===
"
NOT
"
)
{
str_list
.
push
(
"
NOT (
"
);
str_list
.
push
(
this
.
query_list
[
0
].
toString
());
str_list
.
push
(
"
)
"
);
return
str_list
.
join
(
"
"
);
}
this
.
query_list
.
forEach
(
function
(
query
)
{
str_list
.
push
(
"
(
"
);
str_list
.
push
(
query
.
toString
());
str_list
.
push
(
"
)
"
);
str_list
.
push
(
this_operator
);
});
str_list
[
str_list
.
length
-
1
]
=
"
)
"
;
// replace last operator
str_list
.
length
-=
1
;
return
str_list
.
join
(
"
"
);
};
...
...
@@ -79,7 +90,9 @@ ComplexQuery.prototype.serialized = function () {
"
query_list
"
:
[]
};
this
.
query_list
.
forEach
(
function
(
query
)
{
s
.
query_list
.
push
(
query
.
serialized
());
s
.
query_list
.
push
(
typeof
query
.
toJSON
===
"
function
"
?
query
.
toJSON
()
:
query
);
});
return
s
;
};
...
...
src/queries/core/simplequery.js
View file @
aae4a9af
...
...
@@ -77,6 +77,7 @@ function SimpleQuery(spec, key_schema) {
}
inherits
(
SimpleQuery
,
Query
);
SimpleQuery
.
prototype
.
type
=
"
simple
"
;
var
checkKey
=
function
(
key
)
{
var
prop
;
...
...
test/queries/tests.js
View file @
aae4a9af
...
...
@@ -226,6 +226,29 @@
jsoned
,
"
parseStringToObject(
\"
NOT(a:=b OR c:% AND d:<2)
\"
);
"
);
deepEqual
(
jIO
.
QueryFactory
.
create
(
"
NOT(a:=b OR c:% AND d:<2)
"
),
jIO
.
QueryFactory
.
create
(
jIO
.
QueryFactory
.
create
(
"
NOT(a:=b OR c:% AND d:<2)
"
)
),
"
create(create(
\"
NOT(a:=b OR c:% AND d:<2)
\"
));
"
);
deepEqual
(
jIO
.
QueryFactory
.
create
(
jIO
.
QueryFactory
.
create
(
"
NOT(a:=b OR c:% AND d:<2)
"
)
).
toString
(),
"
NOT ( ( a: =
\"
b
\"
) OR ( ( c:
\"
%
\"
) AND ( d: <
\"
2
\"
) ) )
"
,
"
create(create(
\"
NOT(a:=b OR c:% AND d:<2)
\"
)).toString();
"
);
});
}));
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