mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix orderby with multiple labels, closes #4220
This commit is contained in:
parent
f8e4a665bd
commit
7b662b04ff
@ -4,6 +4,9 @@ describe("Lexer fulltext", () => {
|
|||||||
it("simple lexing", () => {
|
it("simple lexing", () => {
|
||||||
expect(lex("hello world").fulltextTokens.map(t => t.token))
|
expect(lex("hello world").fulltextTokens.map(t => t.token))
|
||||||
.toEqual(["hello", "world"]);
|
.toEqual(["hello", "world"]);
|
||||||
|
|
||||||
|
expect(lex("hello, world").fulltextTokens.map(t => t.token))
|
||||||
|
.toEqual(["hello", "world"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("use quotes to keep words together", () => {
|
it("use quotes to keep words together", () => {
|
||||||
@ -147,6 +150,11 @@ describe("Lexer expression", () => {
|
|||||||
expect(lex(`# not(#capital) and note.noteId != "root"`).expressionTokens.map(t => t.token))
|
expect(lex(`# not(#capital) and note.noteId != "root"`).expressionTokens.map(t => t.token))
|
||||||
.toEqual(["#", "not", "(", "#capital", ")", "and", "note", ".", "noteid", "!=", "root"]);
|
.toEqual(["#", "not", "(", "#capital", ")", "and", "note", ".", "noteid", "!=", "root"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("order by multiple labels", () => {
|
||||||
|
expect(lex(`# orderby #a,#b`).expressionTokens.map(t => t.token))
|
||||||
|
.toEqual(["#", "orderby", "#a", ",", "#b"]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Lexer invalid queries and edge cases", () => {
|
describe("Lexer invalid queries and edge cases", () => {
|
||||||
|
@ -11,7 +11,7 @@ function lex(str) {
|
|||||||
let currentWord = '';
|
let currentWord = '';
|
||||||
|
|
||||||
function isSymbolAnOperator(chr) {
|
function isSymbolAnOperator(chr) {
|
||||||
return ['=', '*', '>', '<', '!', "-", "+", '%'].includes(chr);
|
return ['=', '*', '>', '<', '!', "-", "+", '%', ','].includes(chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPreviousSymbolAnOperator() {
|
function isPreviousSymbolAnOperator() {
|
||||||
@ -128,6 +128,10 @@ function lex(str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chr === ',') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
currentWord += chr;
|
currentWord += chr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user