Skip to content

Build your personal knowledge base with Trilium Notes

fix order by note content size, closes #3488

zadam218f526a9235
diff --git a/package-lock.json b/package-lock.json
index dbb36afca0..f33caa45fb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -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": {
diff --git a/src/services/search/expressions/order_by_and_limit.js b/src/services/search/expressions/order_by_and_limit.js
index 45f64e47b9..c36e50388f 100644
--- a/src/services/search/expressions/order_by_and_limit.js
+++ b/src/services/search/expressions/order_by_and_limit.js
@@ -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;
diff --git a/src/services/search/value_extractor.js b/src/services/search/value_extractor.js
index 9534fc3fcd..b8b0f96c72 100644
--- a/src/services/search/value_extractor.js
+++ b/src/services/search/value_extractor.js
@@ -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",