mirror of
https://github.com/zadam/trilium.git
synced 2026-02-27 00:53:35 +01:00
Fix searching with orderby and parentheses / increased expression level (#8717)
Some checks are pending
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / E2E tests on linux-arm64 (push) Waiting to run
playwright / E2E tests on linux-x64 (push) Waiting to run
Some checks are pending
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / E2E tests on linux-arm64 (push) Waiting to run
playwright / E2E tests on linux-x64 (push) Waiting to run
This commit is contained in:
commit
56f796bf80
@ -234,6 +234,32 @@ describe("Parser", () => {
|
||||
expect(rootExp.limit).toBe(2);
|
||||
expect(rootExp.subExpression).toBeInstanceOf(AndExp);
|
||||
});
|
||||
|
||||
describe("orderBy with level > 0", () => {
|
||||
it("and grouping parentheses should parse without error", () => {
|
||||
const searchContext = new SearchContext();
|
||||
const rootExp = parseInternal(
|
||||
{
|
||||
fulltextTokens: [],
|
||||
expressionTokens: tokens(["#foo", "and" , ["#bar", "or", "#baz", ], "orderby", "#priority", "desc"]),
|
||||
searchContext
|
||||
}
|
||||
);
|
||||
expect(searchContext.error).toBeNull();
|
||||
});
|
||||
|
||||
it("and not() should parse without error", () => {
|
||||
const searchContext = new SearchContext();
|
||||
const rootExp = parseInternal(
|
||||
{
|
||||
fulltextTokens: [],
|
||||
expressionTokens: tokens(["#foo", "and" , "not", [ "#bar", "=", "baz" ], "orderby", "#priority", "desc"]) ,
|
||||
searchContext
|
||||
}
|
||||
);
|
||||
expect(searchContext.error).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Invalid expressions", () => {
|
||||
|
||||
@ -361,7 +361,7 @@ function getExpression(tokens: TokenData[], searchContext: SearchContext, level
|
||||
|
||||
for (i = 0; i < tokens.length; i++) {
|
||||
if (Array.isArray(tokens[i])) {
|
||||
const expression = getExpression(tokens[i] as unknown as TokenData[], searchContext, level++);
|
||||
const expression = getExpression(tokens[i] as unknown as TokenData[], searchContext, level + 1);
|
||||
if (expression) {
|
||||
expressions.push(expression);
|
||||
}
|
||||
@ -402,7 +402,7 @@ function getExpression(tokens: TokenData[], searchContext: SearchContext, level
|
||||
}
|
||||
|
||||
const tokenArray = tokens[i] as unknown as TokenData[];
|
||||
const expression = getExpression(tokenArray, searchContext, level++);
|
||||
const expression = getExpression(tokenArray, searchContext, level + 1);
|
||||
if (!expression) {
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user