Skip to content

Commit

Permalink
update uses of subExpression with and
Browse files Browse the repository at this point in the history
  • Loading branch information
qedi-r committed Nov 3, 2024
1 parent 6984f03 commit e875016
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/loot-core/src/server/accounts/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions packages/loot-core/src/server/accounts/transaction-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)],
{},
Expand Down Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/shared/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const TYPE_INFO = {
'doesNotContain',
'notOneOf',
'hasTags',
'subExpression',
'and',
],
nullable: true,
},
Expand Down

0 comments on commit e875016

Please sign in to comment.