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
ba3cb867
Commit
ba3cb867
authored
Mar 10, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into erp5storage
parents
8ef68805
30ce96a4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
8 deletions
+59
-8
jio.js
jio.js
+18
-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.
jio.js
View file @
ba3cb867
...
@@ -4363,7 +4363,7 @@ function ComplexQuery(spec, key_schema) {
...
@@ -4363,7 +4363,7 @@ function ComplexQuery(spec, key_schema) {
* @default "AND"
* @default "AND"
* @optional
* @optional
*/
*/
this
.
operator
=
spec
.
operator
||
"
AND
"
;
this
.
operator
=
spec
.
operator
;
/**
/**
* The sub Query list which are used to query an item.
* The sub Query list which are used to query an item.
...
@@ -4384,6 +4384,9 @@ function ComplexQuery(spec, key_schema) {
...
@@ -4384,6 +4384,9 @@ function ComplexQuery(spec, key_schema) {
}
}
inherits
(
ComplexQuery
,
Query
);
inherits
(
ComplexQuery
,
Query
);
ComplexQuery
.
prototype
.
operator
=
"
AND
"
;
ComplexQuery
.
prototype
.
type
=
"
complex
"
;
/**
/**
* #crossLink "Query/match:method"
* #crossLink "Query/match:method"
*/
*/
...
@@ -4399,12 +4402,20 @@ ComplexQuery.prototype.match = function (item) {
...
@@ -4399,12 +4402,20 @@ ComplexQuery.prototype.match = function (item) {
* #crossLink "Query/toString:method"
* #crossLink "Query/toString:method"
*/
*/
ComplexQuery
.
prototype
.
toString
=
function
()
{
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
)
{
this
.
query_list
.
forEach
(
function
(
query
)
{
str_list
.
push
(
"
(
"
);
str_list
.
push
(
query
.
toString
());
str_list
.
push
(
query
.
toString
());
str_list
.
push
(
"
)
"
);
str_list
.
push
(
this_operator
);
str_list
.
push
(
this_operator
);
});
});
str_list
[
str_list
.
length
-
1
]
=
"
)
"
;
// replace last operator
str_list
.
length
-=
1
;
return
str_list
.
join
(
"
"
);
return
str_list
.
join
(
"
"
);
};
};
...
@@ -4418,7 +4429,9 @@ ComplexQuery.prototype.serialized = function () {
...
@@ -4418,7 +4429,9 @@ ComplexQuery.prototype.serialized = function () {
"
query_list
"
:
[]
"
query_list
"
:
[]
};
};
this
.
query_list
.
forEach
(
function
(
query
)
{
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
;
return
s
;
};
};
...
@@ -4678,6 +4691,7 @@ function SimpleQuery(spec, key_schema) {
...
@@ -4678,6 +4691,7 @@ function SimpleQuery(spec, key_schema) {
}
}
inherits
(
SimpleQuery
,
Query
);
inherits
(
SimpleQuery
,
Query
);
SimpleQuery
.
prototype
.
type
=
"
simple
"
;
var
checkKey
=
function
(
key
)
{
var
checkKey
=
function
(
key
)
{
var
prop
;
var
prop
;
...
...
src/queries/core/complexquery.js
View file @
ba3cb867
...
@@ -24,7 +24,7 @@ function ComplexQuery(spec, key_schema) {
...
@@ -24,7 +24,7 @@ function ComplexQuery(spec, key_schema) {
* @default "AND"
* @default "AND"
* @optional
* @optional
*/
*/
this
.
operator
=
spec
.
operator
||
"
AND
"
;
this
.
operator
=
spec
.
operator
;
/**
/**
* The sub Query list which are used to query an item.
* The sub Query list which are used to query an item.
...
@@ -45,6 +45,9 @@ function ComplexQuery(spec, key_schema) {
...
@@ -45,6 +45,9 @@ function ComplexQuery(spec, key_schema) {
}
}
inherits
(
ComplexQuery
,
Query
);
inherits
(
ComplexQuery
,
Query
);
ComplexQuery
.
prototype
.
operator
=
"
AND
"
;
ComplexQuery
.
prototype
.
type
=
"
complex
"
;
/**
/**
* #crossLink "Query/match:method"
* #crossLink "Query/match:method"
*/
*/
...
@@ -60,12 +63,20 @@ ComplexQuery.prototype.match = function (item) {
...
@@ -60,12 +63,20 @@ ComplexQuery.prototype.match = function (item) {
* #crossLink "Query/toString:method"
* #crossLink "Query/toString:method"
*/
*/
ComplexQuery
.
prototype
.
toString
=
function
()
{
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
)
{
this
.
query_list
.
forEach
(
function
(
query
)
{
str_list
.
push
(
"
(
"
);
str_list
.
push
(
query
.
toString
());
str_list
.
push
(
query
.
toString
());
str_list
.
push
(
"
)
"
);
str_list
.
push
(
this_operator
);
str_list
.
push
(
this_operator
);
});
});
str_list
[
str_list
.
length
-
1
]
=
"
)
"
;
// replace last operator
str_list
.
length
-=
1
;
return
str_list
.
join
(
"
"
);
return
str_list
.
join
(
"
"
);
};
};
...
@@ -79,7 +90,9 @@ ComplexQuery.prototype.serialized = function () {
...
@@ -79,7 +90,9 @@ ComplexQuery.prototype.serialized = function () {
"
query_list
"
:
[]
"
query_list
"
:
[]
};
};
this
.
query_list
.
forEach
(
function
(
query
)
{
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
;
return
s
;
};
};
...
...
src/queries/core/simplequery.js
View file @
ba3cb867
...
@@ -77,6 +77,7 @@ function SimpleQuery(spec, key_schema) {
...
@@ -77,6 +77,7 @@ function SimpleQuery(spec, key_schema) {
}
}
inherits
(
SimpleQuery
,
Query
);
inherits
(
SimpleQuery
,
Query
);
SimpleQuery
.
prototype
.
type
=
"
simple
"
;
var
checkKey
=
function
(
key
)
{
var
checkKey
=
function
(
key
)
{
var
prop
;
var
prop
;
...
...
test/queries/tests.js
View file @
ba3cb867
...
@@ -226,6 +226,29 @@
...
@@ -226,6 +226,29 @@
jsoned
,
jsoned
,
"
parseStringToObject(
\"
NOT(a:=b OR c:% AND d:<2)
\"
);
"
"
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