fix(devserver): use tablesSchemaV2 for Generate Data Model to include primary keys#10519
Open
Funbucket wants to merge 1 commit intocube-js:masterfrom
Open
fix(devserver): use tablesSchemaV2 for Generate Data Model to include primary keys#10519Funbucket wants to merge 1 commit intocube-js:masterfrom
Funbucket wants to merge 1 commit intocube-js:masterfrom
Conversation
… primary keys tablesSchema() only queries information_schema.columns and does not fetch primary key constraints. As a result, no column gets attributes: ['primaryKey'], so the scaffolding never emits primary_key: true in generated YAML files. Replace both calls in DevServer.ts (/playground/db-schema and /playground/generate-schema) with tablesSchemaV2(), which calls primaryKeys() (overridden in each driver with the appropriate query) and merges PK information into column attributes before scaffolding runs. Without this fix, any cube with joins defined fails to compile: "primary key for 'X' is required when join is defined in order to make aggregates work properly" Fixes cube-js#10517
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.
Summary
Fixes #10517
When using Generate Data Model in Cube Playground, primary key columns are not marked with
primary_key: truein the generated YAML, causing compile errors for cubes with joins defined.Root Cause
DevServer.tscallsdriver.tablesSchema()in both endpoints:tablesSchema()queries onlyinformation_schema.columns— it does not fetch primary key constraints. So no column getsattributes: ['primaryKey'], meaningScaffoldingSchemanever setsisPrimaryKey: true, andBaseSchemaFormatternever emitsprimary_key: true.tablesSchemaV2()already exists and does the right thing: it callsprimaryKeys()(implemented per-driver) and merges PK information into column attributes.Fix
Replace both calls with
tablesSchemaV2():Impact
id(the only fallback heuristic inScaffoldingSchema)salesorderid,productid,businessentityid, etc.) is affectedTest plan
salesorderid) — generated YAML should includeprimary_key: true