Commit b53f05b1 authored by Tristan Cavelier's avatar Tristan Cavelier

ComplexQueries put in JIO

See docs/query.rst for more informations
parent be091ae3
......@@ -54,26 +54,25 @@ module.exports = function (grunt) {
// duplicate files are ignored
src: [
'src/jio/intro.js',
// core
'src/jio/core/globals.js',
'src/jio/core/util.js',
'src/jio/core/**/*.js',
'src/jio/features/**/*.js',
'src/jio/outro.js'
],
dest: 'jio.js'
},
queries: {
src: [
'src/queries/begin.js',
// queries
'src/queries/core/globals.js',
'src/queries/core/query.js',
'src/queries/parser-begin.js',
'src/queries/build/parser.js',
'src/queries/parser-end.js',
'src/queries/core/globals.js',
'src/queries/core/tools.js',
'src/queries/core/**/*.js',
'src/queries/end.js'
'src/jio/outro.js'
],
dest: 'complex_queries.js'
dest: 'jio.js'
}
},
uglify: {
......@@ -88,10 +87,6 @@ module.exports = function (grunt) {
jiodate: {
src: 'src/jio.date/jiodate.js',
dest: 'jiodate.min.js'
},
queries: {
src: 'complex_queries.js',
dest: 'complex_queries.min.js'
}
},
qunit: {
......
......@@ -5,8 +5,6 @@ QUERIES_DIR = src/queries
JIO = jio.js
JIO_MIN = jio.min.js
JIODATE_MIN = jiodate.min.js
COMPLEX = complex_queries.js
COMPLEX_MIN = complex_queries.min.js
PARSER_PAR = $(QUERIES_DIR)/core/parser.par
PARSER_OUT = $(QUERIES_DIR)/build/parser.js
UGLIFY = ./node_modules/grunt-contrib-uglify/node_modules/uglify-js/bin/uglifyjs
......@@ -28,7 +26,7 @@ zip:
@mkdir $(TMPDIR)/jio
@mkdir $(TMPDIR)/jio/storage
@cp jio.js $(TMPDIR)/jio/
@cp complex_queries.js $(TMPDIR)/jio/
@cp jioquery.js $(TMPDIR)/jio/
@cp src/sha1.amd.js $(TMPDIR)/jio/
@cp src/sha2.amd.js $(TMPDIR)/jio/
@cp src/sha256.amd.js $(TMPDIR)/jio/
......@@ -57,7 +55,6 @@ zip:
@mkdir $(TMPDIR)/jio/storage
@echo "Minimizing JS..."
@cp jio.min.js $(TMPDIR)/jio/
@cp complex_queries.min.js $(TMPDIR)/jio/
@$(UGLIFY) src/sha1.amd.js >$(TMPDIR)/jio/sha1.amd.min.js 2>/dev/null
@$(UGLIFY) src/sha2.amd.js >$(TMPDIR)/jio/sha2.amd.min.js 2>/dev/null
@$(UGLIFY) src/sha256.amd.js >$(TMPDIR)/jio/sha256.amd.min.js 2>/dev/null
......@@ -92,6 +89,4 @@ realclean:
rm -f "$(JIO)"
rm -f "$(JIO_MIN)"
rm -f "$(JIODATE_MIN)"
rm -f "$(COMPLEX)"
rm -f "$(COMPLEX_MIN)"
rm -f "$(PARSER_OUT)"
......@@ -16,7 +16,6 @@ depending on type of storages being used):
<script src="jio.js"></script>
<!-- jio storage libraries -->
<script src="complex-queries.js"></script>
<script src="localstorage.js"></script>
<script ...>
......@@ -309,13 +308,12 @@ var jio_instance = jIO.createJIO({
For more information on the specific storages including guidelines on how to
create your own connector, please also refer to the [documentation](https://www.j-io.org/documentation/jio-documentation).
### Complex Queries
### jIO Query
jIO uses complex-queries manager, which can be run on top of the allDocs()
method to query documents in the storage tree. A sample query would look like
this (note that not all storages support allDocs and complex queries, and
that pre-querying of documents on distant storages should best be done
server-side):
jIO can use queries, which can be run in the allDocs() method to query document
lists. A sample query would look like this (note that not all storages support
allDocs and jio queries, and that pre-querying of documents on distant storages
should best be done server-side):
```javascript
// run allDocs with query option on an existing jIO
......@@ -342,7 +340,7 @@ jio_instance.allDocs({
});
```
To find out more about complex queries, please refer to the documentation.
To find out more about queries, please refer to the documentation.
### Task Management
......
......@@ -5,7 +5,7 @@ Quick start
-----------
The source repository includes ready-to-use files, so in case you do
not want to build jIO yourself, just use *jio.js* as well as *complex_queries.js*
not want to build jIO yourself, just use *sha256.amd.js*, *rsvp.js*, *jio.js*
plus the storages and dependencies you need and you will be good to go.
If you want to modify or build jIO yourself, you need to
......@@ -311,4 +311,3 @@ Or you can just clear all rules before adding new ones:
// ...
}]
});
......@@ -15,7 +15,6 @@ Getting started
<script src="jio.js"></script>
<!-- storages + dependencies -->
<script src="complex_queries.js"></script>
<script src="localstorage.js"></script>
<script src="davstorage.js"></script>
......@@ -33,7 +32,6 @@ Getting started
rsvp: 'rsvp-custom',
jio: 'jio',
// storages + dependencies
complex_queries: 'complex_queries',
localstorage: 'localstorage',
davstorage: 'davstorage'
}
......@@ -110,7 +108,6 @@ Core
* sha256.amd.js
* rsvp-custom.js, AMD only version: rsvp-custom.amd.js
* jio.js
* complex_queries.js
Storage dependencies
^^^^^^^^^^^^^^^^^^^^
......
......@@ -9,7 +9,8 @@ A storage to enable interoperability between all kind of storages.
A global ID (GID) is a document id which represents a unique document. This ID
is then used to find this unique document on all types of backends.
This storage uses sub storage ``.allDocs()`` and complex queries to find unique documents, and converts their ids to gids.
This storage uses sub storage ``.allDocs()`` and queries to find unique
documents, and converts their ids to gids.
Where it can be used
--------------------
......@@ -125,7 +126,7 @@ Storage Requirements
--------------------
* This storage is not compatible with *RevisionStorage* and *ReplicateRevisionStorage*.
* Sub storages have to support options for ``complex queries`` and ``include_docs``.
* Sub storages have to support options for queries and ``include_docs``.
Dependencies
......@@ -158,5 +159,3 @@ Offline application usage::
`-- Local Storage
**CAUTION: All gid storage must have the same description!**
......@@ -41,10 +41,9 @@ jIO documentation
revision_storages
available_storages
gid_storage
complex_queries
query
keys
metadata
developers
style_guide
authors
......@@ -161,7 +161,7 @@ property, that behaves like the ``compareFunction`` described in
If the < or > comparison makes no sense for the objects, the function should return ``undefined``.
The ``.cmp()`` property is also used, if present, by the sorting feature of complex queries.
The ``.cmp()`` property is also used, if present, by the sorting feature of queries.
......@@ -262,7 +262,7 @@ A schema can be used:
.. code-block:: javascript
complex_queries.QueryFactory.create({...}, key_schema).exec(...);
jIO.QueryFactory.create({...}, key_schema).exec(...);
* In the ``jIO.createJIO()`` method. The same schema will be used
......
......@@ -400,7 +400,7 @@ Posting a job announcement
Getting a list of document created by someone
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With complex query:
With query:
.. code-block:: javascript
......@@ -410,7 +410,7 @@ With complex query:
Getting all documents about jIO in the resilience project
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With complex query:
With query:
.. code-block:: javascript
......
jIO Complex Queries
===================
jIO Query
=========
What are Complex Queries?
-------------------------
What are Queries?
-----------------
In jIO, a complex query can ask a storage server to select, filter, sort, or
limit a document list before sending it back. If the server is not able to do
so, the complex query tool can do the filtering by itself on the client. Only the
``.allDocs()`` method can use complex queries.
In jIO, a query can ask a storage server to select, filter, sort, or limit a
document list before sending it back. If the server is not able to do so, the
jio query tool can do the filtering by itself on the client. Only the
``.allDocs()`` method can use jio queries.
A query can either be a string (using a specific language useful for writing
queries), or it can be a tree of objects (useful to browse queries). To handle
complex queries, jIO uses a parsed grammar file which is compiled using `JSCC <http://jscc.phorward-software.com/>`_.
queries, jIO uses a parsed grammar file which is compiled using `JSCC
<http://jscc.phorward-software.com/>`_.
Why use Complex Queries?
------------------------
Why use JIO Queries?
--------------------
Complex queries can be used like database queries, for tasks such as:
JIO queries can be used like database queries, for tasks such as:
* search a specific document
* sort a list of documents in a certain order
* avoid retrieving a list of ten thousand documents
* limit the list to show only N documents per page
For some storages (like localStorage), complex queries can be a powerful tool
to query accessible documents. When querying documents on a distant storage,
some server-side logic should be run to avoid returning too many documents
to the client. If distant storages are static, an alternative would be to use
an indexStorage with appropriate indices as complex queries will always try
to run the query on the index before querying documents itself.
For some storages (like localStorage), jio queries can be a powerful tool to
query accessible documents. When querying documents on a distant storage, some
server-side logic should be run to avoid returning too many documents to the
client. If distant storages are static, an alternative would be to use an
indexStorage with appropriate indices as jio queries will always try to run the
query on the index before querying documents itself.
How to use Complex Queries with jIO?
------------------------------------
How to use Queries with jIO?
----------------------------
Complex queries can be triggered by including the option named **query** in the ``.allDocs()`` method call.
Queries can be triggered by including the option named **query** in the ``.allDocs()`` method call.
Example:
......@@ -75,26 +76,24 @@ Example:
jio_instance.allDocs(options, callback);
How to use Complex Queries outside jIO?
---------------------------------------
.. XXX 404 page missing on complex_example.html
How to use Queries outside jIO?
-------------------------------
Complex Queries provides an API - which namespace is complex_queries.
Refer to the `Complex Queries sample page <http://git.erp5.org/gitweb/jio.git/blob/HEAD:/examples/complex_example.html?js=1>`_
Refer to the `JIO Query sample page <http://git.erp5.org/gitweb/jio.git/blob/HEAD:/examples/example-queries.html?js=1>`_
for how to use these methods, in and outside jIO. The module provides:
.. code-block:: javascript
{
parseStringToObject: [Function: parseStringToObject],
stringEscapeRegexpCharacters: [Function: stringEscapeRegexpCharacters],
select: [Function: select],
sortOn: [Function: sortOn],
limit: [Function: limit],
searchTextToRegExp: [Function: searchTextToRegExp],
jIO: {
QueryFactory: { [Function: QueryFactory] create: [Function] },
Query: [Function: Query],
Query: { [Function: Query],
parseStringToObject: [Function],
stringEscapeRegexpCharacters: [Function],
select: [Function],
sortOn: [Function],
limit: [Function],
searchTextToRegExp: [Function],
}
SimpleQuery: {
[Function: SimpleQuery] super_: [Function: Query]
},
......@@ -119,7 +118,7 @@ Basic example:
var query = 'title: "Document number 1"';
// running the query
var result = complex_queries.QueryFactory.create(query).exec(object_list);
var result = jIO.QueryFactory.create(query).exec(object_list);
// console.log(result);
// [ { "title": "Document number 1", "creator": "John Doe"} ]
......@@ -128,7 +127,7 @@ Other example:
.. code-block:: javascript
var result = complex_queries.QueryFactory.create(query).exec(
var result = jIO.QueryFactory.create(query).exec(
object_list,
{
"select": ['title', 'year'],
......@@ -138,18 +137,18 @@ Other example:
}
);
// this case is equal to:
var result = complex_queries.QueryFactory.
var result = jIO.QueryFactory.
create(query).exec(object_list);
complex_queries.sortOn([
jIO.Query.sortOn([
['title', 'ascending'],
['year', 'descending']
], result);
complex_queries.limit([20, 20], result);
complex_queries.select(['title', 'year'], result);
jIO.Query.limit([20, 20], result);
jIO.Query.select(['title', 'year'], result);
Complex Queries in storage connectors
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Query in storage connectors
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The query exec method must only be used if the server is not able to pre-select
documents. As mentioned before, you could use an indexStorage to maintain
......@@ -160,7 +159,7 @@ are available in the index.
Matching properties
^^^^^^^^^^^^^^^^^^^
Complex Queries select items which exactly match the value given in the query
Queries select items which exactly match the value given in the query
but you can also use wildcards (``%``). If you don't want to use a wildcard,
just set the operator to ``=``.
......@@ -184,14 +183,14 @@ component (change ``limit: [0, 10]`` to ``limit: [10, 10]`` or ``sort_on: [['tit
'ascending']]`` to ``sort_on: [['creator', 'ascending']]``) and each component must
have its own default properties to keep their own behavior.
Convert Complex Queries into another type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Query into another type
^^^^^^^^^^^^^^^^^^^^^^^
Example, convert Query object into a human readable string:
.. code-block:: javascript
var query = complex_queries.QueryFactory.
var query = jIO.QueryFactory.
create('year: < 2000 OR title: "%a"'),
option = {
limit: [0, 10]
......@@ -240,7 +239,7 @@ JSON Schemas and Grammar
Below you can find schemas for constructing queries.
* Complex Queries JSON Schema:
* Complex Query JSON Schema:
.. code-block:: javascript
......@@ -274,7 +273,7 @@ Below you can find schemas for constructing queries.
}
* Simple Queries JSON Schema:
* Simple Query JSON Schema:
.. code-block:: javascript
......@@ -308,7 +307,7 @@ Below you can find schemas for constructing queries.
* Complex Queries Grammar::
* JIO Query Grammar::
search_text
: and_expression
......
......@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Complex Queries Example</title>
<title>JIO Query Example</title>
<style type="text/css" media="screen">
table, textarea, input {
width: 100%;
......@@ -39,7 +39,6 @@
<button onclick="jsonToSearchText()">JSON to Search text</button>
<button onclick="query()">Query</button>
<script type="text/javascript" src="../lib/rsvp/rsvp-custom.js"></script>
<script type="text/javascript" src="../complex_queries.js"></script>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
......@@ -48,7 +47,7 @@ function searchTextToJson() {
$("#obj").attr(
"value",
JSON.stringify(
complex_queries.QueryFactory.create(
jIO.QueryFactory.create(
$("#str").attr("value")
).serialized()
)
......@@ -57,7 +56,7 @@ function searchTextToJson() {
function jsonToSearchText() {
$("#str").attr(
"value",
complex_queries.QueryFactory.create(
jIO.QueryFactory.create(
JSON.parse(
$("#obj").attr("value")
)
......@@ -66,7 +65,7 @@ function jsonToSearchText() {
}
function query() {
var list = JSON.parse($("#list").attr("value"));
complex_queries.QueryFactory.create(
jIO.QueryFactory.create(
JSON.parse(
$("#obj").attr("value")
)
......
......@@ -19,7 +19,6 @@ var log = function (o) {
<script src="../src/sha256.amd.js"></script>
<script src="../lib/rsvp/rsvp-custom.js"></script>
<script src="../jio.js"></script>
<script src="../complex_queries.js"></script>
<script src="../src/jio.storage/localstorage.js"></script>
<script type="text/javascript">
<!--
......
......@@ -130,7 +130,6 @@ document.addEventListener("keypress", function (event) {
<script src="../lib/rsvp/rsvp-custom.js"></script>
<script src="../src/sha256.amd.js"></script>
<script src="../jio.js"></script>
<script src="../complex_queries.js"></script>
<script src="../src/jio.storage/localstorage.js"></script>
<script src="http://git.erp5.org/gitweb/uritemplate-js.git/blob_plain/HEAD:/bin/uritemplate-min.js"></script>
<script src="../lib/uri/URI.js"></script>
......
......@@ -10,7 +10,7 @@
// }
/*jslint indent: 2, nomen: true, unparam: true */
/*global jIO, complex_queries, console, UriTemplate, FormData, RSVP, URI,
/*global jIO, console, UriTemplate, FormData, RSVP, URI,
ProgressEvent, define */
(function (dependencies, module) {
......@@ -18,13 +18,12 @@
if (typeof define === 'function' && define.amd) {
return define(dependencies, module);
}
module(RSVP, jIO, complex_queries, URI);
module(RSVP, jIO, URI);
}([
'rsvp',
'jio',
'complex_queries',
'uri'
], function (RSVP, jIO, complex_queries, URI) {
], function (RSVP, jIO, URI) {
"use strict";
function ERP5Storage(spec) {
......@@ -176,7 +175,7 @@
ERP5Storage.prototype.allDocs = function (command, param, options) {
if (typeof options.query !== "string") {
options.query = (options.query ?
complex_queries.objectToSearchText(options.query) :
jIO.Query.objectToSearchText(options.query) :
undefined);
}
return this._getSiteDocument()
......
......@@ -23,7 +23,7 @@
* JIO GID Storage. Type = 'gid'.
* Identifies document with their global identifier representation
*
* Sub storages must support complex queries and include_docs options.
* Sub storages must support queries and include_docs options.
*
* Storage Description:
*
......@@ -216,12 +216,12 @@
}
/**
* Convert a gid to a complex query.
* Convert a gid to a jio query.
*
* @param {Object,String} gid The gid
* @return {Object} A complex serialized object
* @return {Object} A jio serialized query
*/
function gidToComplexQuery(gid) {
function gidToJIOQuery(gid) {
var k, i, result = [], meta, content;
if (typeof gid === 'string') {
gid = JSON.parse(gid);
......@@ -300,7 +300,7 @@
* Generic command for post or put one.
*
* This command will check if the document already exist with an allDocs
* and a complex query. If exist, then post will fail. Put will update the
* and a jio query. If exist, then post will fail. Put will update the
* retrieved document thanks to its real id. If no documents are found, post
* and put will create a new document with the sub storage id generator.
*
......@@ -310,7 +310,7 @@
* @param {String} method The command method
*/
priv.putOrPost = function (command, metadata, method) {
var gid, complex_query, doc = tool.deepClone(metadata);
var gid, jio_query, doc = tool.deepClone(metadata);
gid = gidFormat(doc, priv.constraints);
if (gid === undefined || (doc._id && gid !== doc._id)) {
return command.error(
......@@ -319,9 +319,9 @@
"Cannot " + method + " document"
);
}
complex_query = gidToComplexQuery(gid);
jio_query = gidToJIOQuery(gid);
command.storage(priv.sub_storage).allDocs({
"query": complex_query
"query": jio_query
}).then(function (response) {
var update_method = method;
response = response.data;
......@@ -359,7 +359,7 @@
* Generic command for putAttachment, getAttachment or removeAttachment.
*
* This command will check if the document exist with an allDocs and a
* complex query. If not exist, then it returns 404. Otherwise the
* jio query. If not exist, then it returns 404. Otherwise the
* action will be done on the attachment of the found document.
*
* @method putGetOrRemoveAttachment
......@@ -369,7 +369,7 @@
* @param {String} method The command method
*/
priv.putGetOrRemoveAttachment = function (command, doc, method) {
var gid_object, complex_query;
var gid_object, jio_query;
gid_object = gidParse(doc._id, priv.constraints);
if (gid_object === undefined) {
return command.error(
......@@ -378,9 +378,9 @@
"Cannot " + method + " attachment"
);
}
complex_query = gidToComplexQuery(gid_object);
jio_query = gidToJIOQuery(gid_object);
command.storage(priv.sub_storage).allDocs({
"query": complex_query
"query": jio_query
}).then(function (response) {
response = response.data;
if (response.total_rows === 0) {
......@@ -429,7 +429,7 @@
/**
* Puts an attachment to a document thank to its gid, a sub allDocs and a
* complex query.
* jio query.
*
* @method putAttachment
* @param {Command} command The JIO command
......@@ -439,13 +439,13 @@
};
/**
* Gets a document thank to its gid, a sub allDocs and a complex query.
* Gets a document thank to its gid, a sub allDocs and a jio query.
*
* @method get
* @param {Object} command The JIO command
*/
that.get = function (command, param) {
var gid_object, complex_query;
var gid_object, jio_query;
gid_object = gidParse(param._id, priv.constraints);
if (gid_object === undefined) {
return command.error(
......@@ -454,9 +454,9 @@
"Cannot get document"
);
}
complex_query = gidToComplexQuery(gid_object);
jio_query = gidToJIOQuery(gid_object);
command.storage(priv.sub_storage).allDocs({
"query": complex_query,
"query": jio_query,
"include_docs": true
}).then(function (response) {
response = response.data;
......@@ -477,7 +477,7 @@
/**
* Gets an attachment from a document thank to its gid, a sub allDocs and a
* complex query.
* jio query.
*
* @method getAttachment
* @param {Command} command The JIO command
......@@ -487,13 +487,13 @@
};
/**
* Remove a document thank to its gid, sub allDocs and a complex query.
* Remove a document thank to its gid, sub allDocs and a jio query.
*
* @method remove
* @param {Command} command The JIO command.
*/
that.remove = function (command, doc) {
var gid_object, complex_query;
var gid_object, jio_query;
gid_object = gidParse(doc._id, priv.constraints);
if (gid_object === undefined) {
return command.error(
......@@ -502,9 +502,9 @@
"Cannot remove document"
);
}
complex_query = gidToComplexQuery(gid_object);
jio_query = gidToJIOQuery(gid_object);
command.storage(priv.sub_storage).allDocs({
"query": complex_query
"query": jio_query
}).then(function (response) {
response = response.data;
if (response.total_rows === 0) {
......@@ -533,7 +533,7 @@
/**
* Removes an attachment to a document thank to its gid, a sub allDocs and a
* complex query.
* jio query.
*
* @method removeAttachment
* @param {Command} command The JIO command
......
......@@ -17,7 +17,7 @@
*/
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, regexp: true */
/*global window, exports, require, define, jIO, RSVP, complex_queries */
/*global window, exports, require, define, jIO, RSVP */
/**
* JIO Index Storage.
......@@ -122,18 +122,16 @@
return module(
exports,
require('jio'),
require('rsvp'),
require('complex_queries')
require('rsvp')
);
}
window.index_storage = {};
module(window.index_storage, jIO, RSVP, complex_queries);
module(window.index_storage, jIO, RSVP);
}([
'exports',
'jio',
'rsvp',
'complex_queries'
], function (exports, jIO, RSVP, complex_queries) {
'rsvp'
], function (exports, jIO, RSVP) {
"use strict";
/**
......@@ -747,7 +745,7 @@
db[i]["_" + now] = db[i];
}
}
complex_queries.QueryFactory.create(option.query || '').
jIO.QueryFactory.create(option.query || '').
exec(db, option).then(function () {
for (i = 0; i < db.length; i += 1) {
id = db[i]._id;
......
......@@ -5,7 +5,7 @@
*/
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, regexp: true */
/*global jIO, localStorage, setTimeout, complex_queries, window, define,
/*global jIO, localStorage, setTimeout, window, define,
exports, require */
/**
......@@ -54,15 +54,14 @@
return define(dependencies, module);
}
if (typeof exports === 'object') {
return module(exports, require('jio'), require('complex_queries'));
return module(exports, require('jio'));
}
window.local_storage = {};
module(window.local_storage, jIO, complex_queries);
module(window.local_storage, jIO);
}([
'exports',
'jio',
'complex_queries'
], function (exports, jIO, complex_queries) {
'jio'
], function (exports, jIO) {
"use strict";
/**
......@@ -403,7 +402,7 @@
rows = [];
document_list = [];
path_re = new RegExp(
"^" + complex_queries.stringEscapeRegexpCharacters(this._localpath) +
"^" + jIO.Query.stringEscapeRegexpCharacters(this._localpath) +
"/[^/]+$"
);
if (options.query === undefined && options.sort_on === undefined &&
......@@ -426,7 +425,7 @@
}
command.success({"data": {"rows": rows, "total_rows": rows.length}});
} else {
// create complex query object from returned results
// create jio query object from returned results
for (i in this._database) {
if (this._database.hasOwnProperty(i)) {
if (path_re.test(i)) {
......@@ -445,7 +444,7 @@
document_object[meta._id] = meta;
});
}
complex_queries.QueryFactory.create(options.query || "",
jIO.QueryFactory.create(options.query || "",
this._key_schema).
exec(document_list, options).then(function () {
document_list = document_list.map(function (value) {
......
......@@ -16,7 +16,7 @@
return define(dependencies, module);
}
// if (typeof exports === 'object') {
// return module(exports, require('jio'), require('complex_queries'));
// return module(exports, require('jio'));
// }
module(jIO);
}([
......
/*jslint indent: 2, maxlen: 80, nomen: true, regexp: true, unparam: true */
/*global define, RSVP, jIO, complex_queries */
/*global define, RSVP, jIO */
(function (dependencies, module) {
"use strict";
if (typeof define === 'function' && define.amd) {
return define(dependencies, module);
}
module(RSVP, complex_queries, jIO);
}(['rsvp', 'complex_queries', 'jio'], function (RSVP, complex_queries, jIO) {
module(RSVP, jIO);
}(['rsvp', 'jio'], function (RSVP, jIO) {
"use strict";
......@@ -131,7 +131,7 @@
/**
* Retrieve documents.
* This method performs an .allDocs() call on the substorage,
* retrieving everything, then runs a complex query on the result.
* retrieving everything, then runs a query on the result.
*
* @method allDocs
* @param {Object} command The given parameters
......@@ -157,7 +157,7 @@
rows_map[row.id] = row;
});
return complex_queries.QueryFactory.create(options.query,
return jIO.QueryFactory.create(options.query,
that._key_schema).
exec(docs, options).
then(function (filtered_docs) {
......
/*
* Copyright 2013, Nexedi SA
* Released under the LGPL license.
* http://www.gnu.org/licenses/lgpl.html
*/
/**
* Provides some function to use complex queries with item list
*
* @module complex_queries
*/
// define([module_name], [dependencies], module);
(function (dependencies, module) {
"use strict";
if (typeof define === 'function' && define.amd) {
return define(dependencies, module);
}
if (typeof exports === 'object') {
return module(exports);
}
window.complex_queries = {};
module(window.complex_queries, RSVP);
}(['exports', 'rsvp'], function (to_export, RSVP) {
"use strict";
/**
* Add a secured (write permission denied) property to an object.
*
* @param {Object} object The object to fill
* @param {String} key The object key where to store the property
* @param {Any} value The value to store
*/
function _export(key, value) {
Object.defineProperty(to_export, key, {
"configurable": false,
"enumerable": true,
"writable": false,
"value": value
});
}
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global Query: true, query_class_dict: true, inherits: true,
_export, QueryFactory, RSVP, sequence */
exports, QueryFactory, RSVP, sequence */
/**
* The ComplexQuery inherits from Query, and compares one or several metadata
......@@ -195,4 +195,4 @@ ComplexQuery.prototype.NOT = function (item) {
query_class_dict.complex = ComplexQuery;
_export("ComplexQuery", ComplexQuery);
exports.ComplexQuery = ComplexQuery;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global parseStringToObject: true, emptyFunction: true, sortOn: true, limit:
true, select: true, _export: true, stringEscapeRegexpCharacters: true,
true, select: true, exports, stringEscapeRegexpCharacters: true,
deepClone, RSVP, sequence */
/**
......@@ -194,4 +194,4 @@ Query.prototype.serialized = function () {
return undefined;
};
_export("Query", Query);
exports.Query = Query;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global _export, ComplexQuery, SimpleQuery, Query, parseStringToObject,
/*global exports, ComplexQuery, SimpleQuery, Query, parseStringToObject,
query_class_dict */
/**
......@@ -36,4 +36,4 @@ QueryFactory.create = function (object, key_schema) {
"Argument 1 is not a search text or a parsable object");
};
_export("QueryFactory", QueryFactory);
exports.QueryFactory = QueryFactory;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global _export: true */
/*global Query, exports */
function objectToSearchText(query) {
var str_list = [];
......@@ -19,4 +19,4 @@ function objectToSearchText(query) {
}
throw new TypeError("This object is not a query");
}
_export("objectToSearchText", objectToSearchText);
Query.objectToSearchText = objectToSearchText;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global Query: true, inherits: true, query_class_dict: true, _export: true,
/*global Query, inherits, query_class_dict, exports,
searchTextToRegExp, RSVP */
var checkKeySchema = function (key_schema) {
......@@ -384,4 +384,4 @@ SimpleQuery.prototype[">="] = function (object_value, comparison_value) {
query_class_dict.simple = SimpleQuery;
_export("SimpleQuery", SimpleQuery);
exports.SimpleQuery = SimpleQuery;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global _export, RSVP */
/*global Query, RSVP, deepClone */
/**
* Escapes regexp special chars from a string.
......@@ -11,11 +11,11 @@ function stringEscapeRegexpCharacters(string) {
if (typeof string === "string") {
return string.replace(/([\\\.\$\[\]\(\)\{\}\^\?\*\+\-])/g, "\\$1");
}
throw new TypeError("complex_queries.stringEscapeRegexpCharacters(): " +
throw new TypeError("Query.stringEscapeRegexpCharacters(): " +
"Argument no 1 is not of type 'string'");
}
_export("stringEscapeRegexpCharacters", stringEscapeRegexpCharacters);
Query.stringEscapeRegexpCharacters = stringEscapeRegexpCharacters;
/**
* Convert metadata values to array of strings. ex:
......@@ -100,38 +100,10 @@ function sortFunction(key, way) {
return 0;
};
}
throw new TypeError("complex_queries.sortFunction(): " +
throw new TypeError("Query.sortFunction(): " +
"Argument 2 must be 'ascending' or 'descending'");
}
/**
* Clones all native object in deep. Managed types: Object, Array, String,
* Number, Boolean, null.
*
* @param {A} object The object to clone
* @return {A} The cloned object
*/
function deepClone(object) {
var i, cloned;
if (Array.isArray(object)) {
cloned = [];
for (i = 0; i < object.length; i += 1) {
cloned[i] = deepClone(object[i]);
}
return cloned;
}
if (typeof object === "object") {
cloned = {};
for (i in object) {
if (object.hasOwnProperty(i)) {
cloned[i] = deepClone(object[i]);
}
}
return cloned;
}
return object;
}
/**
* Inherits the prototype methods from one constructor into another. The
* prototype of `constructor` will be set to a new object created from
......@@ -171,11 +143,11 @@ function emptyFunction() {
function select(select_option, list, clone) {
var i, j, new_item;
if (!Array.isArray(select_option)) {
throw new TypeError("complex_queries.select(): " +
throw new TypeError("jioquery.select(): " +
"Argument 1 is not of type Array");
}
if (!Array.isArray(list)) {
throw new TypeError("complex_queries.select(): " +
throw new TypeError("jioquery.select(): " +
"Argument 2 is not of type Array");
}
if (clone === true) {
......@@ -198,7 +170,7 @@ function select(select_option, list, clone) {
return list;
}
_export('select', select);
Query.select = select;
/**
* Sort a list of items, according to keys and directions. If `clone` is true,
......@@ -212,7 +184,7 @@ _export('select', select);
function sortOn(sort_on_option, list, clone) {
var sort_index;
if (!Array.isArray(sort_on_option)) {
throw new TypeError("complex_queries.sortOn(): " +
throw new TypeError("jioquery.sortOn(): " +
"Argument 1 is not of type 'array'");
}
if (clone) {
......@@ -228,7 +200,7 @@ function sortOn(sort_on_option, list, clone) {
return list;
}
_export('sortOn', sortOn);
Query.sortOn = sortOn;
/**
* Limit a list of items, according to index and length. If `clone` is true,
......@@ -241,11 +213,11 @@ _export('sortOn', sortOn);
*/
function limit(limit_option, list, clone) {
if (!Array.isArray(limit_option)) {
throw new TypeError("complex_queries.limit(): " +
throw new TypeError("jioquery.limit(): " +
"Argument 1 is not of type 'array'");
}
if (!Array.isArray(list)) {
throw new TypeError("complex_queries.limit(): " +
throw new TypeError("jioquery.limit(): " +
"Argument 2 is not of type 'array'");
}
if (clone) {
......@@ -258,7 +230,7 @@ function limit(limit_option, list, clone) {
return list;
}
_export('limit', limit);
Query.limit = limit;
/**
* Convert a search text to a regexp.
......@@ -269,7 +241,7 @@ _export('limit', limit);
*/
function searchTextToRegExp(string, use_wildcard_characters) {
if (typeof string !== 'string') {
throw new TypeError("complex_queries.searchTextToRegExp(): " +
throw new TypeError("jioquery.searchTextToRegExp(): " +
"Argument 1 is not of type 'string'");
}
if (use_wildcard_characters === false) {
......@@ -284,7 +256,7 @@ function searchTextToRegExp(string, use_wildcard_characters) {
) + "$");
}
_export("searchTextToRegExp", searchTextToRegExp);
Query.searchTextToRegExp = searchTextToRegExp;
/**
* sequence(thens): Promise
......
return to_export;
}));
return result;
} // parseStringToObject
_export('parseStringToObject', parseStringToObject);
Query.parseStringToObject = parseStringToObject;
......@@ -9,7 +9,6 @@
<script src="../../lib/rsvp/rsvp-custom.js"></script>
<script src="../../src/sha256.amd.js"></script>
<script src="../../jio.js"></script>
<script src="../../complex_queries.js"></script>
<script src="../../src/jio.storage/davstorage.js"></script>
<script src="../jio/util.js"></script>
</head>
......
......@@ -10,7 +10,6 @@
<script src="../../lib/jquery/jquery.min.js"></script>
<script src="../../src/sha256.amd.js"></script>
<script src="../../jio.js"></script>
<script src="../../complex_queries.js"></script>
<script src="../../src/sha1.amd.js"></script>
<script src="../../src/jio.storage/gidstorage.js"></script>
<script src="../../src/jio.storage/s3storage.js"></script>
......
......@@ -10,7 +10,6 @@
<script src="../../lib/jquery/jquery.min.js"></script>
<script src="../../src/sha256.amd.js"></script>
<script src="../../jio.js"></script>
<script src="../../complex_queries.js"></script>
<script src="../../src/sha1.amd.js"></script>
<script src="../../src/jio.storage/s3storage.js"></script>
<script src="../../src/jio.storage/splitstorage.js"></script>
......
......@@ -10,7 +10,6 @@
<script src="../../lib/jquery/jquery.min.js"></script>
<script src="../../src/sha256.amd.js"></script>
<script src="../../jio.js"></script>
<script src="../../complex_queries.js"></script>
<script src="../../src/sha1.amd.js"></script>
<script src="../../src/jio.storage/s3storage.js"></script>
<script src="../jio/util.js"></script>
......
/*jslint indent: 2, maxlen: 120, nomen: true, vars: true */
/*global define, exports, require, module, complex_queries, jiodate, window, test, ok,
equal, deepEqual, sinon, start, stop, RSVP */
/*global define, exports, require, module, jIO, jiodate, window, test,
ok, equal, deepEqual, sinon, start, stop, RSVP */
// define([module_name], [dependencies], module);
(function (dependencies, module) {
......@@ -9,10 +9,10 @@
return define(dependencies, module);
}
if (typeof exports === 'object') {
return module(require('complex_queries'), require('jiodate'));
return module(require('jio'), require('jiodate'));
}
module(complex_queries, jiodate);
}(['complex_queries', 'jiodate', 'qunit'], function (complex_queries, jiodate) {
module(jIO, jiodate);
}(['jio', 'jiodate', 'qunit'], function (jIO, jiodate) {
"use strict";
module('Custom Key Queries with JIODate');
......@@ -40,7 +40,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'date',
value: '2011'
......@@ -54,7 +54,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'date',
operator: '!=',
......@@ -70,7 +70,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'date',
operator: '<',
......@@ -85,7 +85,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'date',
operator: '<=',
......@@ -101,7 +101,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'date',
operator: '>',
......@@ -116,7 +116,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'date',
operator: '>=',
......@@ -150,7 +150,7 @@
query_list.forEach(function (o) {
var qs = o[0], expected = o[1];
promise.push(
complex_queries.QueryFactory.create(qs, key_schema).
jIO.QueryFactory.create(qs, key_schema).
exec(docList()).
then(function (dl) {
deepEqual(dl, expected, "Match with '" + qs + "' (parsed query string)");
......@@ -167,7 +167,7 @@
query_list.forEach(function (qs) {
promise.push(
complex_queries.QueryFactory.create(qs, key_schema).
jIO.QueryFactory.create(qs, key_schema).
exec(docList()).
then(function (dl) {
deepEqual(dl, [
......
/*jslint indent: 2, maxlen: 100, nomen: true, vars: true */
/*global define, exports, require, module, complex_queries, window, test, ok,
/*global define, exports, require, module, jIO, window, test, ok,
deepEqual, sinon, start, stop, RSVP */
// define([module_name], [dependencies], module);
......@@ -9,10 +9,10 @@
return define(dependencies, module);
}
if (typeof exports === 'object') {
return module(require('complex_queries'));
return module(require('jio'));
}
module(complex_queries);
}(['complex_queries', 'qunit'], function (complex_queries) {
module(jIO);
}(['jio', 'qunit'], function (jIO) {
"use strict";
module('Custom Key Queries with Schema');
......@@ -104,7 +104,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'case_insensitive_identifier',
value: 'A'
......@@ -137,7 +137,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'date_day',
value: '2013-02-02'
......@@ -151,7 +151,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'date_month',
value: '2013-02-10'
......@@ -167,7 +167,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'date_year',
value: '2013-02-10'
......@@ -182,7 +182,7 @@
});
test('Test key schema + complex queries', function () {
test('Test key schema + jio query', function () {
var docList = function () {
return [
{'identifier': '10', 'number': '10'},
......@@ -209,7 +209,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'complex',
operator: 'OR',
query_list: [{
......@@ -248,7 +248,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'translated_state',
value: 'ouvert'
......@@ -262,7 +262,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: 'translated_state',
operator: '=',
......@@ -279,7 +279,7 @@
// XXX not implemented yet
// doc_list = docList();
// complex_queries.QueryFactory.create({
// jIO.QueryFactory.create({
// type: 'simple',
// key: 'translated_state',
// operator: '!=',
......
/*jslint indent: 2, maxlen: 90, nomen: true */
/*global define, exports, require, module, complex_queries, window, test,
/*global define, exports, require, module, jIO, window, test,
raises, ok, equal, deepEqual, sinon */
// define([module_name], [dependencies], module);
......@@ -9,17 +9,17 @@
return define(dependencies, module);
}
if (typeof exports === 'object') {
return module(require('complex_queries'));
return module(require('jio'));
}
module(complex_queries);
}(['complex_queries', 'qunit'], function (complex_queries) {
module(jIO);
}(['jio', 'qunit'], function (jIO) {
"use strict";
module('Key and key_schema objects validation');
test('Check the parameters passed to exec() and create()', function () {
try {
complex_queries.QueryFactory.create('').exec('gnegne');
jIO.QueryFactory.create('').exec('gnegne');
ok(false, 'argument 1 not checked');
} catch (e) {
equal(e.name, 'TypeError', 'wrong exception type');
......@@ -29,7 +29,7 @@
}
try {
complex_queries.QueryFactory.create({});
jIO.QueryFactory.create({});
ok(false, 'argument 1 not checked');
} catch (e) {
equal(e.name, 'TypeError', 'wrong exception type');
......@@ -39,7 +39,7 @@
}
try {
complex_queries.QueryFactory.create('').exec([], 1);
jIO.QueryFactory.create('').exec([], 1);
ok(false, 'argument 2 not checked');
} catch (e) {
equal(e.name, 'TypeError', 'wrong exception type');
......@@ -49,7 +49,7 @@
}
try {
complex_queries.QueryFactory.create({type: 'simple'}, '');
jIO.QueryFactory.create({type: 'simple'}, '');
ok(false, 'key_schema type is not checked');
} catch (e) {
equal(e.name, 'TypeError', 'wrong exception type');
......@@ -59,7 +59,7 @@
}
try {
complex_queries.QueryFactory.create({type: 'simple'}, {});
jIO.QueryFactory.create({type: 'simple'}, {});
ok(false, 'key_schema.key_set is not checked');
} catch (e) {
equal(e.name, 'TypeError', 'wrong exception type');
......@@ -69,7 +69,9 @@
}
try {
complex_queries.QueryFactory.create({type: 'simple'}, {key_set: {}, foobar: {}});
jIO.QueryFactory.create({
type: 'simple'
}, {key_set: {}, foobar: {}});
ok(false, 'unknown key_schema properties are not checked');
} catch (e) {
equal(e.name, 'TypeError', 'wrong exception type');
......@@ -87,7 +89,7 @@
];
try {
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: {},
value: 'a'
......@@ -101,7 +103,7 @@
}
try {
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: {
read_from: 'identifier',
......
/*jslint indent: 2, maxlen: 120, nomen: true, vars: true */
/*global define, exports, require, module, complex_queries, window, test, ok,
/*global define, exports, require, module, jIO, window, test, ok,
equal, deepEqual, sinon, stop, start, RSVP */
// define([module_name], [dependencies], module);
......@@ -9,10 +9,10 @@
return define(dependencies, module);
}
if (typeof exports === 'object') {
return module(require('complex_queries'));
return module(require('jio'));
}
module(complex_queries);
}(['complex_queries', 'qunit'], function (complex_queries) {
module(jIO);
}(['jio', 'qunit'], function (jIO) {
"use strict";
module('Custom Key Queries');
......@@ -43,7 +43,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.title,
value: 'a'
......@@ -57,7 +57,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.case_insensitive_identifier,
value: 'A'
......@@ -136,7 +136,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.day,
value: '2013-02-02'
......@@ -150,7 +150,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.month,
value: '2013-02-10'
......@@ -166,7 +166,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.year,
value: '2013-02-10'
......@@ -199,7 +199,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.mydate,
operator: '=',
......@@ -214,7 +214,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.mydate,
operator: '!=',
......@@ -230,7 +230,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.mydate,
operator: '<=',
......@@ -246,7 +246,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.mydate,
operator: '<',
......@@ -261,7 +261,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.mydate,
operator: '>',
......@@ -276,7 +276,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.mydate,
operator: '>=',
......@@ -315,7 +315,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.mydate,
value: '2013-02-02'
......@@ -329,7 +329,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.mydate,
operator: '=',
......@@ -344,7 +344,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.mydate,
operator: '>=',
......@@ -381,7 +381,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: {
read_from: 'number',
......@@ -399,7 +399,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: {
read_from: 'number',
......@@ -417,7 +417,7 @@
);
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'complex',
operator: 'OR',
query_list: [{
......@@ -477,7 +477,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.translated_state,
value: 'ouvert'
......@@ -492,7 +492,7 @@
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.translated_state,
operator: '=',
......@@ -508,7 +508,7 @@
// XXX not implemented yet
// doc_list = docList();
// complex_queries.QueryFactory.create({
// jIO.QueryFactory.create({
// type: 'simple',
// key: keys.translated_state,
// operator: '!=',
......@@ -579,7 +579,7 @@
stop();
promise.push(
complex_queries.QueryFactory.create({
jIO.QueryFactory.create({
type: 'simple',
key: keys.identifier,
value: 'aei%'
......
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, exports, require, module, complex_queries, window, test, ok,
/*global define, exports, require, module, jIO, window, test, ok,
deepEqual, stop, start */
// define([module_name], [dependencies], module);
......@@ -9,13 +9,13 @@
return define(dependencies, module);
}
if (typeof exports === 'object') {
return module(require('complex_queries'));
return module(require('jio'));
}
module(complex_queries);
}(['complex_queries', 'qunit'], function (complex_queries) {
module(jIO);
}(['jio', 'qunit'], function (jIO) {
"use strict";
module('Complex Queries');
module('Query');
// XXX test documentation
test('Empty Query', function () {
......@@ -24,7 +24,7 @@
{"identifier": ["b", "c"]}
];
stop();
complex_queries.QueryFactory.create('').exec(doc_list).
jIO.QueryFactory.create('').exec(doc_list).
then(function (doc_list) {
deepEqual(doc_list, [
{"identifier": "a"},
......@@ -39,7 +39,7 @@
{"identifier": ["b", "c"]}
];
stop();
complex_queries.QueryFactory.create('identifier: "a"').exec(doc_list).
jIO.QueryFactory.create('identifier: "a"').exec(doc_list).
then(function (doc_list) {
deepEqual(doc_list, [
{"identifier": "a"}
......@@ -50,7 +50,7 @@
{"identifier": ["a", "b"]}
];
return complex_queries.QueryFactory.create('identifier: "a"').
return jIO.QueryFactory.create('identifier: "a"').
exec(doc_list);
}).then(function (doc_list) {
deepEqual(doc_list, [
......@@ -66,7 +66,7 @@
{"identifier": ["b", "c"]}
];
stop();
complex_queries.QueryFactory.create(
jIO.QueryFactory.create(
'identifier: "b" AND identifier: "c"'
).exec(doc_list).then(function (doc_list) {
deepEqual(doc_list, [
......@@ -77,7 +77,7 @@
{"identifier": "a"},
{"identifier": ["b", "c"]}
];
return complex_queries.QueryFactory.create(
return jIO.QueryFactory.create(
'identifier: "a" OR identifier: "c"'
).exec(doc_list);
}).then(function (doc_list) {
......@@ -91,7 +91,7 @@
{"identifier": ["b", "c"]}
];
return complex_queries.QueryFactory.create(
return jIO.QueryFactory.create(
'(identifier: "a" OR identifier: "b") AND title: "o"'
).exec(doc_list);
}).then(function (doc_list) {
......@@ -109,7 +109,7 @@
{"identifier": ["ab", "b"]}
];
stop();
complex_queries.QueryFactory.create('identifier: "a%"').exec(
jIO.QueryFactory.create('identifier: "a%"').exec(
doc_list
).then(function (doc_list) {
deepEqual(doc_list, [
......@@ -126,7 +126,7 @@
{"identifier": ["ab", "b"]}
];
return complex_queries.QueryFactory.create('identifier: "a\\%"').
return jIO.QueryFactory.create('identifier: "a\\%"').
exec(doc_list);
}).then(function (doc_list) {
deepEqual(doc_list, [
......@@ -142,7 +142,7 @@
{"identifier": ["ab", "b"]}
];
return complex_queries.QueryFactory.create('identifier: "__"').
return jIO.QueryFactory.create('identifier: "__"').
exec(doc_list);
}).then(function (doc_list) {
deepEqual(doc_list, [
......@@ -155,7 +155,7 @@
{"identifier": ["ab", "b"]}
];
return complex_queries.QueryFactory.create('identifier: "__%"').
return jIO.QueryFactory.create('identifier: "__%"').
exec(doc_list);
}).then(function (doc_list) {
deepEqual(doc_list, [
......@@ -175,7 +175,7 @@
{"identifier": "b", "title": "d"}
];
stop();
complex_queries.QueryFactory.create('').exec(doc_list, {
jIO.QueryFactory.create('').exec(doc_list, {
"select_list": ["title"],
"limit": [2, 1],
"sort_on": [["identifier", "ascending"], ["title", "descending"]]
......@@ -187,7 +187,7 @@
});
test("JSON query", function () {
var jsoned = complex_queries.QueryFactory.create(
var jsoned = jIO.QueryFactory.create(
"NOT(a:=b OR c:% AND d:<2)"
).toJSON();
deepEqual(
......@@ -222,7 +222,7 @@
"\"NOT(a:=b OR c:% AND d:<2)\".toJSON()"
);
deepEqual(
complex_queries.parseStringToObject("NOT(a:=b OR c:% AND d:<2)"),
jIO.Query.parseStringToObject("NOT(a:=b OR c:% AND d:<2)"),
jsoned,
"parseStringToObject(\"NOT(a:=b OR c:% AND d:<2)\");"
);
......
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="../lib/qunit/qunit.css" />
<title>JIO, Storage and ComplexQueries Qunit/Sinon Unit Tests</title>
<title>JIO Qunit/Sinon Unit Tests</title>
</head>
<body>
<div id="qunit"></div>
......@@ -18,7 +18,6 @@
<script src="jio/fakestorage.js"></script>
<script src="jio/tests.js"></script>
<script src="../complex_queries.js"></script>
<script src="queries/key.tests.js"></script>
<script src="queries/key-schema.tests.js"></script>
<script src="queries/tests.js"></script>
......
......@@ -14,8 +14,7 @@
"test_util": "jio/util",
"fakestorage": "jio/fakestorage",
"complex_queries": "../complex_queries",
"complex_queries_tests": "queries/tests",
"jioquery_tests": "queries/tests",
"localstorage": "../src/jio.storage/localstorage",
"localstorage_tests": "jio.storage/localstorage.tests",
......@@ -53,7 +52,7 @@
require([
"sinon_qunit",
"jio_tests",
"complex_queries_tests",
"jioquery_tests",
"localstorage_tests",
"davstorage_tests",
"indexstorage_tests",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment