Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

expr: OR queries with date: are not handled correctly #2178

Copy link
Copy link

Description

@redneb
Issue body actions

I am trying to use the balance command with an expr: query that includes a date: term, but I am getting incorrect results.

Here's a complete but very minimal example. I have the following journal file (with just one transaction):

2023-12-22
	expense:food            10.00
	asset:wallet

and I am running the following command:

$ hledger balance expr:'(date:2024-01 AND acct:expense:food) OR (date:2023-12 AND acct:expense:drinks)'
               10.00  expense:food
--------------------
               10.00  

As you can see, balance takes into account the transaction that occurred on 2023-12-22 (which is the only transaction in this minimal example), even though it does not match with the date term which is date:2024-01 (i.e. January of 2024). Interestingly enough, if I remove the second operand of OR, which should have been inconsequential as it is a sub-expression that doesn't match with anything, the problem goes away:

$ hledger balance expr:'(date:2024-01 AND acct:expense:food)'
--------------------
                   0  

This is counterintuitive: mathematically speaking, <subexpr1> is superset of <subexpr1> OR <subexpr2>, so removing terms from the disjunction should not make the balance smaller, it should only increase it.

Note that this problem does not affect print, as print seems to pickup the correct transactions. But it does affect register and possibly other commands.

Finally:

$ hledger --version
hledger 1.32.3, linux-x86_64
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-BUGSomething wrong, confusing or sub-standard in the software, docs, or user experience.Something wrong, confusing or sub-standard in the software, docs, or user experience.affects4-manyAffects potentially a significant number of users.Affects potentially a significant number of users.annoyance2-minorMinor to moderate usability/doc bug, reasonably easy to avoid or tolerate.Minor to moderate usability/doc bug, reasonably easy to avoid or tolerate.queriesFiltering options, query arguments..Filtering options, query arguments..

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.