mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
better detection of float parameter in label filters, fixes #265
This commit is contained in:
parent
de9e0c7929
commit
86bc84a2ad
@ -23,9 +23,15 @@ module.exports = function(attributeFilters) {
|
|||||||
whereParams.push(filter.value);
|
whereParams.push(filter.value);
|
||||||
}
|
}
|
||||||
else if ([">", ">=", "<", "<="].includes(filter.operator)) {
|
else if ([">", ">=", "<", "<="].includes(filter.operator)) {
|
||||||
const floatParam = parseFloat(filter.value);
|
let floatParam;
|
||||||
|
|
||||||
if (isNaN(floatParam)) {
|
// from https://stackoverflow.com/questions/12643009/regular-expression-for-floating-point-numbers
|
||||||
|
if (/^[+-]?([0-9]*[.])?[0-9]+$/.test(filter.value)) {
|
||||||
|
floatParam = parseFloat(filter.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (floatParam === undefined || isNaN(floatParam)) {
|
||||||
|
// if the value can't be parsed as float then we assume that string comparison should be used instead of numeric
|
||||||
where += `attribute${i}.value ${filter.operator} ?`;
|
where += `attribute${i}.value ${filter.operator} ?`;
|
||||||
whereParams.push(filter.value);
|
whereParams.push(filter.value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user