Commit 71e8158b authored by Nicolas Wavrant's avatar Nicolas Wavrant

query.js: do not raise if the sort_on_option list is empty

parent b08e246c
...@@ -157,6 +157,9 @@ ...@@ -157,6 +157,9 @@
throw new TypeError("jioquery.sortOn(): " + throw new TypeError("jioquery.sortOn(): " +
"Argument 1 is not of type 'array'"); "Argument 1 is not of type 'array'");
} }
if (sort_on_option.length === 0) {
return list;
}
list.sort(generateSortFunction( list.sort(generateSortFunction(
key_schema, key_schema,
sort_on_option sort_on_option
......
...@@ -642,6 +642,30 @@ ...@@ -642,6 +642,30 @@
}); });
});*/ });*/
test('Empty sort_on options do not raise', function () {
var doc_list = [
{'a': 1},
{'c': 3},
{'b': 2}
];
stop();
expect(1);
jIO.QueryFactory.create("").exec(
doc_list,
{
sort_on: [],
}
)
.then(function (list) {
deepEqual(list, [
{'a': 1},
{'c': 3},
{'b': 2}
], 'Sorting didn\'t raise');
}).always(start);
});
test('Multiple sort_on options', function () { test('Multiple sort_on options', function () {
var i, var i,
len = 1000, len = 1000,
......
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