Skip to content

fix(er): support left-side numeric entity identifier 1#7598

Open
Gaston202 wants to merge 2 commits intomermaid-js:developfrom
Gaston202:bug/7472_er-left-side-1-identifier
Open

fix(er): support left-side numeric entity identifier 1#7598
Gaston202 wants to merge 2 commits intomermaid-js:developfrom
Gaston202:bug/7472_er-left-side-1-identifier

Conversation

@Gaston202
Copy link
Copy Markdown
Contributor

@Gaston202 Gaston202 commented Apr 10, 2026

Disambiguate numeric token handling in ER parser so left-side entity name "1" works in relationship statements, while preserving right-side numeric entity cases from #7472.

  • refine lexer lookahead for cardinality token 1
  • allow ONLY_ONE token where an entity name is valid
  • add regression tests for left-side forms: "1 1 to many" and "1 many to many"

Refs #7472

📑 Summary

This PR fixes an ER parser regression where the left-side entity name "1" could be interpreted as cardinality in relationship statements.

It disambiguates numeric token handling so left-side numeric entity names parse correctly, while preserving the right-side numeric entity behavior introduced in #7472.

Resolves #7472

📏 Design Decisions

  • Refined lexer lookahead handling for token 1 to avoid over-greedy matching in ambiguous relationship contexts.
  • Allowed ONLY_ONE in entity-name parsing context so numeric identifier "1" can be treated as an entity where valid.
  • Added regression tests to cover both left-side forms:
    • 1 1 to many SomeEntity: label
    • 1 many to many SomeEntity: label

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit tests for the regression
  • 📓 have added documentation. Not required for this bug fix because no new feature or syntax was introduced.
  • 🦋 If this fix should be included in changelogs, generate a changeset with patch level and prefix fix:.

Disambiguate numeric token handling in ER parser so left-side entity name '1' works in relationship statements, while preserving right-side numeric entity cases from mermaid-js#7472.\n\n- refine lexer lookahead for cardinality token 1\n- allow ONLY_ONE token where an entity name is valid\n- add regression tests for left-side forms: '1 1 to many' and '1 many to many'\n\nRefs mermaid-js#7472
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 10, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 2c6966b
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/69d9329bf6bea20008dc2bc7
😎 Deploy Preview https://deploy-preview-7598--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 10, 2026

⚠️ No Changeset found

Latest commit: 2c6966b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added the Type: Bug / Error Something isn't working or is incorrect label Apr 10, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 10, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/@mermaid-js/examples@7598

mermaid

npm i https://pkg.pr.new/mermaid@7598

@mermaid-js/layout-elk

npm i https://pkg.pr.new/@mermaid-js/layout-elk@7598

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/@mermaid-js/layout-tidy-tree@7598

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/@mermaid-js/mermaid-zenuml@7598

@mermaid-js/parser

npm i https://pkg.pr.new/@mermaid-js/parser@7598

@mermaid-js/tiny

npm i https://pkg.pr.new/@mermaid-js/tiny@7598

commit: 2c6966b

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.33%. Comparing base (57e5f54) to head (2c6966b).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #7598   +/-   ##
=======================================
  Coverage     3.33%   3.33%           
=======================================
  Files          536     536           
  Lines        56249   56249           
  Branches       820     820           
=======================================
  Hits          1876    1876           
  Misses       54373   54373           
Flag Coverage Δ
unit 3.33% <ø> (ø)

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

🚀 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.

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 1 changed Apr 10, 2026, 5:36 PM

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

Labels

Type: Bug / Error Something isn't working or is incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ER Diagram] parsing error when using 1 as identifier in right side of relationship that uses the 1 cardinality alias

1 participant