feat: add TAGS() macro and auto-detection for multi-tag AND queries#202
Merged
feat: add TAGS() macro and auto-detection for multi-tag AND queries#202
Conversation
Introduces two complementary solutions for the common mistake of filtering
by multiple tags with AND (which always returns zero results):
1. TAGS() macro: explicit opt-in syntax
WHERE TAGS('#project', '#active')
→ path IN (SELECT path FROM tags WHERE tag = '#project'
INTERSECT SELECT path FROM tags WHERE tag = '#active')
2. Auto-detection: transparently rewrites the broken pattern
WHERE tag = '#a' AND tag = '#b'
→ path IN (...INTERSECT...)
Mixed conditions (AND name = 'test') are preserved correctly.
Both use INTERSECT subqueries which are more flexible than an EXISTS
approach (no hardcoded table reference required).
Adds disableTagAutoDetection setting so advanced users can opt out of
the transparent rewrite and handle the SQL themselves.
Docs updated in query-vault-content.md and faq/understanding-tags.md.
f37ff64 to
939c6df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces two complementary solutions for the common mistake of filtering by multiple tags with AND (which always returns zero results):
TAGS() macro: explicit opt-in syntax WHERE TAGS('#project', '#active') → path IN (SELECT path FROM tags WHERE tag = '#project' INTERSECT SELECT path FROM tags WHERE tag = '#active')
Auto-detection: transparently rewrites the broken pattern WHERE tag = '#a' AND tag = '#b' → path IN (...INTERSECT...) Mixed conditions (AND name = 'test') are preserved correctly.
Both use INTERSECT subqueries which are more flexible than an EXISTS approach (no hardcoded table reference required).
Adds disableTagAutoDetection setting so advanced users can opt out of the transparent rewrite and handle the SQL themselves.
Docs updated in query-vault-content.md and faq/understanding-tags.md.