From e8750166dac71c2e3ec5f5e0d527dd26c87ab4c4 Mon Sep 17 00:00:00 2001 From: Ryan Bianchi <1435081+qedi-r@users.noreply.github.com> Date: Sun, 3 Nov 2024 14:51:56 -0500 Subject: [PATCH] update uses of subExpression with and --- packages/loot-core/src/server/accounts/rules.ts | 2 +- .../loot-core/src/server/accounts/transaction-rules.test.ts | 2 +- packages/loot-core/src/server/accounts/transaction-rules.ts | 6 +++--- packages/loot-core/src/shared/rules.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts index 3f9f17b7267..20f9ea2d219 100644 --- a/packages/loot-core/src/server/accounts/rules.ts +++ b/packages/loot-core/src/server/accounts/rules.ts @@ -204,7 +204,7 @@ const CONDITION_TYPES = { ], nullable: true, parse(op, value, fieldName) { - if (op === 'oneOf' || op === 'notOneOf' || op === 'subExpression') { + if (op === 'oneOf' || op === 'notOneOf' || op === 'and') { assert( Array.isArray(value), 'no-empty-array', diff --git a/packages/loot-core/src/server/accounts/transaction-rules.test.ts b/packages/loot-core/src/server/accounts/transaction-rules.test.ts index aa7e7fbd3e2..c418ef8f9b8 100644 --- a/packages/loot-core/src/server/accounts/transaction-rules.test.ts +++ b/packages/loot-core/src/server/accounts/transaction-rules.test.ts @@ -510,7 +510,7 @@ describe('Transaction rules', () => { // todo: isapprox }); - test('subexpression builds $and condition', async () => { + test('and sub expression builds $and condition', async () => { const conds = [{ field: 'category', op: 'is', value: null }]; debugger; const { filters } = conditionsToAQL(conds); diff --git a/packages/loot-core/src/server/accounts/transaction-rules.ts b/packages/loot-core/src/server/accounts/transaction-rules.ts index 3b5d6015018..a41bd40020b 100644 --- a/packages/loot-core/src/server/accounts/transaction-rules.ts +++ b/packages/loot-core/src/server/accounts/transaction-rules.ts @@ -295,7 +295,7 @@ function conditionSpecialCases(cond: Condition): Condition { //special cases that require multiple conditions if (cond.op === 'is' && cond.field === 'category' && cond.value === null) { return new Condition( - 'subExpression', + 'and', cond.field, [ cond, @@ -310,7 +310,7 @@ function conditionSpecialCases(cond: Condition): Condition { cond.value === null ) { return new Condition( - 'subExpression', + 'and', cond.field, [cond, new Condition('is', 'parent', false, null)], {}, @@ -541,7 +541,7 @@ export function conditionsToAQL(conditions, { recurDateBounds = 100 } = {}) { return apply(field, '$eq', true); case 'false': return apply(field, '$eq', false); - case 'subExpression': + case 'and': debugger; return { $and: getValue(value).map(subExpr => mapConditionToActualQL(subExpr)), diff --git a/packages/loot-core/src/shared/rules.ts b/packages/loot-core/src/shared/rules.ts index 26cda525af0..56d34de34e3 100644 --- a/packages/loot-core/src/shared/rules.ts +++ b/packages/loot-core/src/shared/rules.ts @@ -20,7 +20,7 @@ const TYPE_INFO = { 'doesNotContain', 'notOneOf', 'hasTags', - 'subExpression', + 'and', ], nullable: true, },