Skip to content

feat(schema-compiler): capitalize ID acronyms in default meta titles#11047

Open
keydunov wants to merge 1 commit into
masterfrom
fix/meta-titleize-id-acronyms
Open

feat(schema-compiler): capitalize ID acronyms in default meta titles#11047
keydunov wants to merge 1 commit into
masterfrom
fix/meta-titleize-id-acronyms

Conversation

@keydunov

@keydunov keydunov commented Jun 9, 2026

Copy link
Copy Markdown
Member

Check List

  • Tests have been run in packages where changes have been made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Description of Changes Made

Default member titles in the meta are generated via titleize() in CubeToMetaTransformer, which used inflection.titleize. That rendered the identifier suffix as "Id":

  • userId"User Id"
  • an id member → "Id"

This post-processes the titleized string to uppercase the Id/Ids token at word boundaries, so default titles read naturally:

member before after
id Id ID
userId User Id User ID
userIds User Ids User IDs
orderId Order Id Order ID
identityProvider Identity Provider Identity Provider (unchanged)
idaho Idaho Idaho (unchanged)

The word-boundary regex only touches the standalone Id/Ids token, so words like "Identity" or "Idaho" are unaffected. Explicit title: overrides in the data model are unaffected since titleize is only the fallback.

🤖 Generated with Claude Code

Default member titles are generated via titleize(), which used
inflection.titleize and rendered the identifier suffix as "Id" — so
`userId` became "User Id" and an `id` member became "Id".

Post-process the titleized string to uppercase the Id/Ids token at word
boundaries, so titles read naturally: "User ID", "User IDs", "ID". The
word-boundary match leaves words like "Identity" and "Idaho" untouched,
and explicit title overrides are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@keydunov keydunov requested a review from a team as a code owner June 9, 2026 18:40
@github-actions github-actions Bot added the javascript Pull requests that update Javascript code label Jun 9, 2026
@claude

claude Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Claude finished @keydunov's task in 31s —— View job


Code Review

Verdict: LGTM — small, well-scoped change. 0 high, 0 medium, 1 low.

Details

Checklist

  • Read changed file (CubeToMetaTransformer.ts)
  • Verify regex behavior against the cases listed in the PR description
  • Check for missed cases / regressions
  • Note test coverage

Correctness

The implementation in packages/cubejs-schema-compiler/src/compiler/CubeToMetaTransformer.ts:475-480 is correct:

private titleize(name: string): string {
  const titleized = inflection.titleize(inflection.underscore(camelCase(name, { pascalCase: true })));
  return titleized.replace(/\bId(s?)\b/g, (_match, plural) => `ID${plural}`);
}

Walking through the cases:

  • userIdUser IdUser ID
  • idIdID
  • userIdsUser IdsUser IDs
  • identityProviderIdentity Provider\bId\b doesn't match Identity (no word boundary after Id) ✓
  • idahoIdaho — same, unaffected ✓

The \b boundaries correctly protect against false positives, and applying the post-processing only inside titleize() keeps explicit title: overrides untouched (they short-circuit at CubeToMetaTransformer.ts:471).

Low — missing test coverage

The PR description's table is essentially a test spec, but no test was added. Given this method affects every default member/cube title rendered in meta, a small unit test pinning the documented behavior would prevent future regressions (e.g. someone swapping the regex to /Id/g and breaking "Identity"). Worth considering adding a focused test in the schema-compiler package covering id, userId, userIds, identityProvider, and idaho.

Other considerations

  • Scope: only Id/Ids are handled. Other common acronyms (URL, API, UUID, IP) still render titleized (e.g. apiKeyApi Key). That's a reasonable scoping decision for this PR; flagging only so it's an intentional choice rather than an oversight.
  • No security or performance concerns — single regex replace on a short string per member at compile time.
• [`fix/meta-titleize-id-acronyms`](https://github.com/cube-js/cube/tree/fix/meta-titleize-id-acronyms)

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.51%. Comparing base (d91df4b) to head (8525471).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #11047   +/-   ##
=======================================
  Coverage   58.51%   58.51%           
=======================================
  Files         216      216           
  Lines       17265    17266    +1     
  Branches     3524     3524           
=======================================
+ Hits        10102    10103    +1     
  Misses       6648     6648           
  Partials      515      515           
Flag Coverage Δ
cube-backend 58.51% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant