Commit a2f84507 authored by Romain Courteaud's avatar Romain Courteaud

WIP query sort with null value

parent 397bd917
Pipeline #35746 failed with stage
in 0 seconds
......@@ -47,7 +47,10 @@
value = [value];
}
for (i = 0; i < value.length; i += 1) {
if ((value[i] !== null) && (typeof value[i] === 'object')) {
if (value[i] === null) {
new_value[i] = undefined;
} else if (typeof value[i] === 'object') {
//if (typeof value[i] === 'object') {
new_value[i] = value[i].content;
} else {
new_value[i] = value[i];
......@@ -119,8 +122,10 @@
}
// this comparison is 5 times faster than json comparison
console.log(a[key], b[key]);
a_string_array = metadataValueToStringArray(a[key]) || [];
b_string_array = metadataValueToStringArray(b[key]) || [];
console.log(a_string_array, b_string_array);
l = Math.max(a_string_array.length, b_string_array.length);
for (i = 0; i < l; i += 1) {
if (a_string_array[i] === undefined) {
......
......@@ -716,9 +716,11 @@
test('sort_on options do not raise in case of null value', function () {
var doc_list = [
{'a': null},
{'c': 3},
{'b': 2}
{'a': null, 'b': 5},
{'a': null, 'b': 4},
{'a': 3, 'b': 3},
{'a': 2, 'b': 2},
{'a': null, 'b': 1}
];
stop();
......@@ -726,13 +728,16 @@
jIO.QueryFactory.create("").exec(
doc_list,
{
sort_on: [['a', 'ascending']],
sort_on: [
['a', 'descending'],
['b', 'ascending'],
],
}
)
.then(function (list) {
deepEqual(list, [
{'c': 3},
{'b': 2},
{'a': 3},
{'a': 2},
{'a': null}
], 'Sorting didn\'t raise');
}).always(start);
......
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