Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespaced classes lose members if relation statement comes after namespace #4519

Closed
sduveen-pivot opened this issue Jun 22, 2023 · 1 comment · Fixed by #4532
Closed

namespaced classes lose members if relation statement comes after namespace #4519

sduveen-pivot opened this issue Jun 22, 2023 · 1 comment · Fixed by #4532
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@sduveen-pivot
Copy link

Description

When a relation is declared after a namespace, the members disappear.

The following diagram will not include the +Id: Guid in either class

    classDiagram
      namespace A {
        class A1 {
          +Id : Guid
        }
      }
      namespace B {
        class B1 {
          +Id: Guid
        }
      }
      A1 --> B1

while

    classDiagram
      A1 --> B1
      namespace A {
        class A1 {
          +Id : Guid
        }
      }
      namespace B {
        class B1 {
          +Id: Guid
        }
      }

will display the +Id: Guid because the relationships are before the namespace declaration.

Steps to reproduce

See Description and code sample

Screenshots

mermaid_bug1

Code Sample

classDiagram
      namespace A {
        class A1 {
          +Id : Guid
        }
      }
      namespace B {
        class B1 {
          +Id: Guid
        }
      }
      A1 --> B1

Setup

  • Mermaid version: 3662869 (on develop branch)
  • Browser and Version: [Chrome, Firefox]

Additional Context

This is a bug in the parser/classDb file.
Namespaces depend on successfully deleting the class from the base classes variable:

delete classes[className];

However, when relations are added, they call addClass() (again)

export const addRelation = function (relation: ClassRelation) {
log.debug('Adding relation: ' + JSON.stringify(relation));
addClass(relation.id1);
addClass(relation.id2);

and so the class is re-instantiated w/o the members that were 'known" from adding to namespaces

@sduveen-pivot sduveen-pivot added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Jun 22, 2023
@duaneking
Copy link

duaneking commented Mar 19, 2024

This is not fixed and even the live mermaid renderer does not seem to work as expected in my tests.

Adding a namespace removed all the connections; for accessibility and code clarity the connections between objects are defined in the class that has them, and should not be defined outside of the namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants