question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation: Are parenthesis able to group logical operators?

See original GitHub issue

Please provide a link to the documentation page and section

https://blacksmithgu.github.io/obsidian-dataview/api/code-reference/#dvpagessource

Describe the problem

  • The documentation doesn’t say whether parenthesis are a valid way to group logical operators.
  • For example, I’d like to do dv.pages('"dir" and (#tag1 or #tag2)') to find all documents in “dir/” that contain EITHER tag1 OR tag2. Documents must only match from the “dir” folder. Initial testing seems to confirm that this works, but it’s not documented anywhere.
  • Another example query is dv.pages('"dir" and (#tag1 and #tag2)') to find all documents in “dir/” that contain BOTH tag1 AND tag2.
  • If both of those queries are legal/valid, what about something even more complex, such as this? dv.pages('"dir" and (#tag1 and (#tag2 or #tag3))') - Is that valid?
  • What about groups with just one operand, like this? dv.pages('"dir" and (#tag1) and (#tag2)') - is this valid?

Describe the solution you’d like

  • Can you confirm whether the syntax I just described is legal/safe to use?
  • If so, it would be very useful to document it on the dv.pages() API page among the other examples listed there. 😃

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
blacksmithgucommented, Jun 28, 2022

Yes, arbitrary nesting is fine - Dataview uses a parser combinator library which supports LL(infinity) grammars, including all the standard things you expect out of an expression parser like in JavaScript.

1reaction
blacksmithgucommented, Jun 28, 2022

Fixed in documentation; will show up during the 0.5.38 release later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grouping operator ( ) - JavaScript - MDN Web Docs
The grouping operator consists of a pair of parentheses around an expression that groups the contents. The operator overrides the normal ...
Read more >
Should I fully parenthesize expressions or rely on precedence ...
Good developers strive to write code that is clear and correct. Parentheses in conditionals, even if they are not strictly required, help with...
Read more >
powershell - Using parenthesis for multiple logical operations
The logical AND operator -and converts the values designated by its operands to bool, ... So this determines the rules for adding (or...
Read more >
Search Operators | GovInfo
Parentheses are used to group words and expressions so that the result of evaluating the expression between the parentheses can be used as...
Read more >
Rule operators and grouping symbols - Cloudflare Docs
The Cloudflare Rules language supports comparison and logical operators: ... Use parentheses to explicitly group expressions that should be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found