mirror of
https://github.com/zadam/trilium.git
synced 2025-01-18 04:59:56 +08:00
fix order by note content size, closes #3488
This commit is contained in:
parent
161b45aa12
commit
218f526a92
3 changed files with 17 additions and 8 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -1,12 +1,11 @@
|
|||
{
|
||||
"name": "trilium",
|
||||
"version": "0.58.2-beta",
|
||||
"version": "0.58.3-beta",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "trilium",
|
||||
"version": "0.58.2-beta",
|
||||
"version": "0.58.3-beta",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
|
|
|
@ -48,14 +48,13 @@ class OrderByAndLimitExp extends Expression {
|
|||
}
|
||||
|
||||
// if both are numbers then parse them for numerical comparison
|
||||
// beware that isNaN will return false for empty string and null
|
||||
if (valA.trim() !== "" && valB.trim() !== "" && !isNaN(valA) && !isNaN(valB)) {
|
||||
if (this.isNumber(valA) && this.isNumber(valB)) {
|
||||
valA = parseFloat(valA);
|
||||
valB = parseFloat(valB);
|
||||
}
|
||||
|
||||
if (!valA && !valB) {
|
||||
// the attribute is not defined in either note so continue to next order definition
|
||||
// the attribute value is empty/zero in both notes so continue to the next order definition
|
||||
continue;
|
||||
} else if (!valB || valA < valB) {
|
||||
return smaller;
|
||||
|
@ -77,6 +76,17 @@ class OrderByAndLimitExp extends Expression {
|
|||
|
||||
return noteSet;
|
||||
}
|
||||
|
||||
isNumber(x) {
|
||||
if (typeof x === 'number') {
|
||||
return true;
|
||||
} else if (typeof x === 'string') {
|
||||
// isNaN will return false for blank string
|
||||
return x.trim() !== "" && !isNaN(x);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = OrderByAndLimitExp;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* Search string is lower cased for case insensitive comparison. But when retrieving properties
|
||||
* we need case sensitive form so we have this translation object.
|
||||
* Search string is lower cased for case-insensitive comparison. But when retrieving properties
|
||||
* we need case-sensitive form, so we have this translation object.
|
||||
*/
|
||||
const PROP_MAPPING = {
|
||||
"noteid": "noteId",
|
||||
|
|
Loading…
Reference in a new issue