Replies: 1 comment
-
|
PR is up: #1648 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Type: Feature (additive, backwards-compatible)
Summary
Add a
subtreeoperator to collectionwheretaxonomy filters so selecting a parent term matches that term and all of its descendants, resolved in SQL:Today the taxonomy
wherefilter matches by exact slug only. There is no way to express "this term or anything filed under it" — the natural meaning of selecting a parent category in a faceted browse UI.The problem
The only workaround for "term-or-descendants" is to enumerate the whole subtree on the client and pass every descendant slug. The loader expands that to one bound parameter per slug:
That collides with a hard platform limit:
D1_ERROR: too many SQL variables.pnpm dev, not only in production.This can't be fixed cleanly in the consumer:
whereAPI exposes only exact-slug matching, so "descendant of X" is inexpressible without enumerating the subtree — which is exactly what overflows.limit/cursorcan't spanIN-chunked queries and still return one correctly-ordered page).taxonomies.parent_id); recomputing the subtree in the consumer and shipping hundreds of slugs across the call boundary is the wrong layer.Proposed solution
Resolve the subtree server-side from a single root slug, so the bound-parameter count is independent of subtree size:
WhereValueshape —{ subtree: slug | slug[] }— alongside today's exact["slug"]form. Purely additive; existing filters are unchanged.content_taxonomies.taxonomy_idagainst the set of translation-groups in the subtree, produced by a recursive walk oftaxonomies.parent_id. After fix: store translation_group in taxonomy parent_id to stop cross-locale parent leak #1646 both columns live in translation_group space, so the walk is locale-correct and matching needs no extra join.Secondary (opt-in): a
rollupoption ongetTaxonomyTerms(and the admin terms endpoint) that returns distinct-entry subtree counts, so a facet badge equals what selecting that facet actually returns. Default counts are unchanged.Why it's low-risk
parent_idsemantics).subtree:is present in awhereclause.sql.ref()identifiers), and counts stay honest viaCOUNT(DISTINCT entry_id).Status
A complete, reviewed implementation is ready to open as a PR once this is approved: the
subtreeoperator, the distinct-count rollup, dialect-parity tests (including a >999-descendant overflow regression guard and a distinct-count honesty test), and a changeset.Questions for maintainers
whereAPI?{ subtree: … }vs.{ descendantsOf: … }— before the PR?Happy to adjust the API shape to match your conventions.
Beta Was this translation helpful? Give feedback.
All reactions