postData is keyed by (slug, locale, version), and sync-post writes one row per version (frontmatter version field, default ""). No query in the codebase today has an explicit, documented way to pick "the current version" when more than one exists for the same slug+locale:
Right now this is latent rather than actively broken, since no real content currently has a non-empty version. But if Playful Programming's post-rewrite/versioning feature ever populates a real non-empty version for live, current content, both of the above will silently return the wrong row (or duplicate rows) for affected posts.
Proposal
Decide on one real convention for "the current version of a post" — options to consider:
- An explicit
isCurrent/isLatest boolean column on postData.
- "Max version wins" (requires
version to be orderable, which a free-text frontmatter field currently isn't).
- Something else
sync-post already knows at write time that could be persisted instead of inferred at query time.
Once decided:
Context
Surfaced while building #83 (GET /content/posts) — see the "Open design question" section on PR #184 for the specific stopgap this issue is meant to replace.
postDatais keyed by(slug, locale, version), andsync-postwrites one row per version (frontmatterversionfield, default""). No query in the codebase today has an explicit, documented way to pick "the current version" when more than one exists for the sameslug+locale:GET /content/post/:slug(Endpoint for get post by ID #80,post.ts) takespost.data[0]from an unordered, unfiltered relational query result — whichever row the DB happens to return first.GET /content/posts(Endpoint to return a list of posts #83,posts.ts) pins its join toversion = "", matching the schema default and every existing fixture, but this is a stopgap, not an established convention — flagged as an open design question on PR feat(api): add GET /content/posts list endpoint #184.Right now this is latent rather than actively broken, since no real content currently has a non-empty
version. But if Playful Programming's post-rewrite/versioning feature ever populates a real non-empty version for live, current content, both of the above will silently return the wrong row (or duplicate rows) for affected posts.Proposal
Decide on one real convention for "the current version of a post" — options to consider:
isCurrent/isLatestboolean column onpostData.versionto be orderable, which a free-text frontmatter field currently isn't).sync-postalready knows at write time that could be persisted instead of inferred at query time.Once decided:
post.tsto select the current version explicitly instead ofdata[0].posts.tsto use the same convention instead of theversion = ""stopgap.Context
Surfaced while building #83 (
GET /content/posts) — see the "Open design question" section on PR #184 for the specific stopgap this issue is meant to replace.