fix(cubejs): scaffolded cubes with joins get a primary-key dimension#70
Merged
Conversation
ScaffoldingTemplate emits belongsTo joins for FK-pattern columns but only
auto-marks a primary key for columns literally named 'id'. Schemas keyed
with '<table>_id' (e.g. Pagila) then scaffold cubes that have joins and no
primary_key — and the whole branch fails to compile ('primary key for X is
required when join is defined'), so generate-models produces a datasource
whose meta serves ZERO cubes.
Post-process YAML scaffolds: when a cube has joins and no primary-key
dimension, promote the id-pattern column (id / <table>_id / trailing _id
not used by a join) to a hidden primary-key dimension.
Surfaced by cxs2 spec 081 (US7b: connect Pagila -> generate models ->
dashboard); verified against the local stack.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
acmeguy
added a commit
that referenced
this pull request
Jul 13, 2026
Follow-up to #70: cube requires a primary key on BOTH sides of a join — 'primary key for X is required when join is defined' also fires for the referenced cube (Rental belongsTo Customer ⇒ Customer needs a pk). Add the hidden id-pattern primary-key dimension to every scaffolded cube that has one, not only cubes that own joins. Verified: 3-table Pagila scaffold now compiles and serves Rental/Film/Customer. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
ScaffoldingTemplate emits
belongsTojoins for FK-pattern columns but only auto-marks a primary key for columns literally namedid. Schemas keyed<table>_id(e.g. Pagila) then scaffold cubes with joins and no primary_key — the whole branch fails to compile (primary key for X is required when join is defined) and the datasource's meta serves zero cubes.Fix: post-process YAML scaffolds — when a cube has joins and no primary-key dimension, promote the id-pattern column to a hidden primary-key dimension.
Surfaced by cxs2 spec 081 (US7b: connect Pagila → generate models → Tychi refine → dashboard). Verified locally: 3-table Pagila scaffold now compiles and serves Film/Customer/Rental.
🤖 Generated with Claude Code