Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!!: Disallow mixing delimiter types in Boolean queries #2762

Merged
merged 22 commits into from Apr 9, 2024

Conversation

claremacrae
Copy link
Collaborator

Description

Disallow the mixing of (...) and "..." delimiters in Boolean queries.

This reduces the number of scenarios in which we will accidentally treat a character in the filter as a delimiter.

Since the documentation discouraged use of " as a delimiter, it is unlikely to break any/many real-world searches - but it is a breaking change.

Note: more improvements are coming so I am not updating the documentation yet.

Example change

This mixture used to be allowed:

"not done" AND (is recurring)

It now gives the error:

Tasks query: Could not interpret the following instruction as a Boolean combination:
    "not done" AND (is recurring)

The error message is:
    All filters in a Boolean instruction must be inside one of these pairs of delimiter characters: (...) or "...". Combinations of those delimiters are no longer supported.

Example benefit

For example, it fixes this filter, where previously the closing " was wrongly interpreted:

(description includes "hello world") OR (description includes "42")

This query used to give:

Could not interpret the following instruction as a Boolean combination:
    (description includes "hello world") OR (description includes "42")

The error message is:
    malformed boolean query -- Unexpected character: " (check the documentation for guidelines)

The instruction was converted to the following simplified line:
    (f1") OR (f2")

Where the sub-expressions in the simplified line are:
    'f1': 'description includes "hello world'
    'f2': 'description includes "42'

For help, see:
    https://publish.obsidian.md/tasks/Queries/Combining+Filters

It now works, giving this explanation:

  (description includes "hello world") OR (description includes "42") =>
    OR (At least one of):
      description includes "hello world"
      description includes "42"

Motivation and Context

Reduce the number of pitfalls in Boolean queries.

How has this been tested?

  • Automated tests
  • Exploratory testing

Types of changes

Changes visible to users:

  • Breaking change (prefix: feat!! or fix!! - fix or feature that would cause existing functionality to not work as expected)
  • Documentation (prefix: docs - improvements to any documentation content for users)
    Contributing to Tasks)

Internal changes:

  • Refactor (prefix: refactor - non-breaking change which only improves the design or structure of existing code, and making no changes to its external behaviour)
  • Tests (prefix: test - additions and improvements to unit tests and the smoke tests)

Checklist

  • My code follows the code style of this project and passes yarn run lint.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
    • Will be done later
  • My change has adequate Unit Test coverage.

Terms

It now checks the first delimiter on the line is the same type as the last one.
This reduces the number of scenarios in which we will accidentally
treat a character in the filter as a delimiter.

For example, it fixes this filter:
    (description includes "hello world") OR (description includes "42")

Since the documentation discouraged use of " as a delimiter, it is
unlikely to break any/many real-world searches - but it is a breaking change.
@claremacrae claremacrae added the scope: query logic Boolean combinations of filters - and, or, not label Apr 9, 2024
@claremacrae claremacrae merged commit 687b5b8 into main Apr 9, 2024
2 checks passed
@claremacrae claremacrae deleted the auto-detect-boolean-delimiter branch April 9, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: query logic Boolean combinations of filters - and, or, not
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant