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
aed2d3c3
Commit
aed2d3c3
authored
Dec 19, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added key schema support to complex queries, fixed and added tests
parent
0b8f4cd2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
4 deletions
+52
-4
src/queries/core/complexquery.js
src/queries/core/complexquery.js
+2
-2
test/queries/key-schema.tests.js
test/queries/key-schema.tests.js
+48
-0
test/queries/keys.tests.js
test/queries/keys.tests.js
+2
-2
No files found.
src/queries/core/complexquery.js
View file @
aed2d3c3
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* @param {String} spec.key The metadata key
* @param {String} spec.key The metadata key
* @param {String} spec.value The value of the metadata to compare
* @param {String} spec.value The value of the metadata to compare
*/
*/
function
ComplexQuery
(
spec
)
{
function
ComplexQuery
(
spec
,
key_schema
)
{
Query
.
call
(
this
);
Query
.
call
(
this
);
/**
/**
...
@@ -38,7 +38,7 @@ function ComplexQuery(spec) {
...
@@ -38,7 +38,7 @@ function ComplexQuery(spec) {
/*jslint unparam: true*/
/*jslint unparam: true*/
this
.
query_list
=
this
.
query_list
.
map
(
this
.
query_list
=
this
.
query_list
.
map
(
// decorate the map to avoid sending the index as key_schema argument
// decorate the map to avoid sending the index as key_schema argument
function
(
o
,
i
)
{
return
QueryFactory
.
create
(
o
);
}
function
(
o
,
i
)
{
return
QueryFactory
.
create
(
o
,
key_schema
);
}
);
);
/*jslint unparam: false*/
/*jslint unparam: false*/
...
...
test/queries/key-schema.tests.js
View file @
aed2d3c3
...
@@ -168,6 +168,54 @@
...
@@ -168,6 +168,54 @@
});
});
test
(
'
Test key schema + complex queries
'
,
function
()
{
var
doc_list
,
docList
=
function
()
{
return
[
{
'
identifier
'
:
'
10
'
,
'
number
'
:
'
10
'
},
{
'
identifier
'
:
'
19
'
,
'
number
'
:
'
19
'
},
{
'
identifier
'
:
'
100
'
,
'
number
'
:
'
100
'
}
];
},
key_schema
=
{
types
:
{
intType
:
function
(
value
)
{
if
(
typeof
value
===
'
string
'
)
{
return
parseInt
(
value
,
10
);
}
return
value
;
}
},
keys
:
{
number
:
{
readFrom
:
'
number
'
,
castTo
:
'
intType
'
}
}
};
doc_list
=
docList
();
complex_queries
.
QueryFactory
.
create
({
type
:
'
complex
'
,
operator
:
'
OR
'
,
query_list
:
[{
type
:
'
simple
'
,
key
:
'
number
'
,
operator
:
'
<
'
,
value
:
'
19
'
},
{
type
:
'
simple
'
,
key
:
'
number
'
,
operator
:
'
=
'
,
value
:
'
19
'
}]
},
key_schema
).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
{
'
identifier
'
:
'
10
'
,
'
number
'
:
'
10
'
},
{
'
identifier
'
:
'
19
'
,
'
number
'
:
'
19
'
}
],
'
Key schema should be propagated from complex to simple queries
'
);
});
test
(
'
Key Schema with translation lookup
'
,
function
()
{
test
(
'
Key Schema with translation lookup
'
,
function
()
{
var
doc_list
,
docList
=
function
()
{
var
doc_list
,
docList
=
function
()
{
return
[
return
[
...
...
test/queries/keys.tests.js
View file @
aed2d3c3
...
@@ -357,13 +357,13 @@
...
@@ -357,13 +357,13 @@
readFrom
:
'
number
'
,
readFrom
:
'
number
'
,
castTo
:
intType
castTo
:
intType
},
},
operator
:
'
>
'
,
operator
:
'
=
'
,
value
:
'
19
'
value
:
'
19
'
}]
}]
}).
exec
(
doc_list
);
}).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
deepEqual
(
doc_list
,
[
{
'
identifier
'
:
'
10
'
,
'
number
'
:
'
10
'
},
{
'
identifier
'
:
'
10
'
,
'
number
'
:
'
10
'
},
{
'
identifier
'
:
'
1
00
'
,
'
number
'
:
'
100
'
}
{
'
identifier
'
:
'
1
9
'
,
'
number
'
:
'
19
'
}
],
'
Custom keys should also work within compound queries
'
);
],
'
Custom keys should also work within compound queries
'
);
});
});
...
...
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