Skip to content

feat: add TAGS() macro and auto-detection for multi-tag AND queries#202

Merged
kulak-at merged 2 commits intomainfrom
feat/main-meh-multi-tag
Apr 6, 2026
Merged

feat: add TAGS() macro and auto-detection for multi-tag AND queries#202
kulak-at merged 2 commits intomainfrom
feat/main-meh-multi-tag

Conversation

@kulak-at
Copy link
Copy Markdown
Member

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.

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.
@kulak-at kulak-at force-pushed the feat/main-meh-multi-tag branch from f37ff64 to 939c6df Compare March 22, 2026 22:42
@kulak-at kulak-at marked this pull request as ready for review April 6, 2026 11:45
@kulak-at kulak-at merged commit c038366 into main Apr 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant