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