Filter with locical expressions does not work
To report a bug...
If I use two filters, I would assume that the logical or expression would have as result the join of both expressions.
- What command(s) did you run?
1st command:
task "+asap" count
399
2nd command:
task "project:Weekend" count
91
3rd command:
task "project:Weekend or +asap" count
0
4th command:
task "+asap or project:Weekend" count
468
- What did you expect to happen?
- I would assume that 3rd and 4th command give the same result.
- I would assume that 3rd command would not result in zero count. Instead, it should be at least the maximum of command 1 and command 2.
- What actually happened?
The result depends on the order of the two arguments (math: Commutative law).
- Paste the output of the
task diagcommand.
Platform: Linux
Compiler
Version: 13.1.1 20230429
Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64
Compliance: C++17
Build Features
CMake: 3.26.3
libuuid: libuuid + uuid_unparse_lower
libgnutls: 3.8.0
Build type:
Configuration
File: /home/people/XXX/.taskrc (found), 2786 bytes, mode 100644
Data: /home/people/XXX/.task (found), dir, mode 40755
Locking: Enabled
GC: Enabled
Hooks
System: Enabled
Location: /home/people/XXX/.task/hooks
(-none-)
Tests
Terminal: 220x64
Dups: Scanned 1406 tasks for duplicate UUIDs:
No duplicates found
Broken ref: Scanned 1406 tasks for broken references:
No broken references found
Walking through the examples with rc.debug.parser=2, we end up with "project:Weekend or +asap" parsing like this:
_original_args
task ( status:pending -WAITING limit:page ) next rc.debug.parser=2 project:Weekend or +asap
_args
word basename='task' raw='task' BINARY
op raw='(' QUOTED FILTER
dom canonical='status' modifier='' raw='status' FILTER
op raw='=' FILTER
string raw='pending' FILTER
op raw='and' FILTER
dom raw='tags' FILTER
op raw='_notag_' FILTER
string raw='WAITING' FILTER
op raw='and' FILTER
word canonical='limit' modifier='' name='limit' raw='limit:page' separator=':' value='page' FILTER
op raw=')' QUOTED FILTER
identifier canonical='next' raw='next' CMD READONLY SHOWSID RUNSGC USESCONTEXT ALLOWSFILTER
pair modifier='debug.parser' name='rc' raw='rc.debug.parser=2' separator='=' value='2' CONFIG ORIGINAL
op raw='and' FILTER
op raw='(' ORIGINAL FILTER
dom canonical='project' modifier='' raw='project' FILTER
op raw='=' FILTER
string raw='Weekend or +asap' FILTER
op raw=')' ORIGINAL FILTER
And "+asap or project:Weekend" parsing like this:
CLI2::prepareFilter insertJunctions
_original_args
task ( status:pending -WAITING limit:page ) next rc.debug.parser=2 +asap or project:Weekend
_args
word basename='task' raw='task' BINARY
op raw='(' QUOTED FILTER
dom canonical='status' modifier='' raw='status' FILTER
op raw='=' FILTER
string raw='pending' FILTER
op raw='and' FILTER
dom raw='tags' FILTER
op raw='_notag_' FILTER
string raw='WAITING' FILTER
op raw='and' FILTER
word canonical='limit' modifier='' name='limit' raw='limit:page' separator=':' value='page' FILTER
op raw=')' QUOTED FILTER
identifier canonical='next' raw='next' CMD READONLY SHOWSID RUNSGC USESCONTEXT ALLOWSFILTER
pair modifier='debug.parser' name='rc' raw='rc.debug.parser=2' separator='=' value='2' CONFIG ORIGINAL
op raw='and' FILTER
op raw='(' ORIGINAL FILTER
dom raw='tags' FILTER
op raw='_hastag_' FILTER
string raw='asap' FILTER
op raw='or' FILTER
dom canonical='project' modifier='' raw='project' FILTER
op raw='=' FILTER
string raw='Weekend' FILTER
op raw=')' ORIGINAL FILTER
So it sees the "project:Weekend or +asap" filter as project:"Weekend or +asap", whereas it's clever enough to understand that the "+asap or projectWeekend" isn't a single tag named asap or project:Weekend. I think whether that's a problem with the parser depends on whether spaces in project names are expected to be supported, and I don't know the answer to that.
Note, though, that for these queries you can skip the quotes; task project:Weekend or +asap and task +asap or project:Weekend work as you'd expect.