Merge pull request #4588 from ibrahimWassouf/enhancement/4158_Add_primary_key_beginning_with_asterisk

Allow entity diagram attribute names to start with asterisk
This commit is contained in:
Sidharth Vinod
2023-07-17 09:26:46 +00:00
committed by GitHub
4 changed files with 35 additions and 4 deletions

View File

@@ -200,6 +200,27 @@ describe('Entity Relationship Diagram', () => {
); );
}); });
it('should render entities with attributes that begin with asterisk', () => {
imgSnapshotTest(
`
erDiagram
BOOK {
int *id
string name
varchar(99) summary
}
BOOK }o..o{ STORE : soldBy
STORE {
int *id
string name
varchar(50) address
}
`,
{ loglevel: 1 }
);
cy.get('svg');
});
it('should render entities with keys', () => { it('should render entities with keys', () => {
renderGraph( renderGraph(
` `

View File

@@ -196,7 +196,7 @@ erDiagram
} }
``` ```
The `type` and `name` values must begin with an alphabetic character and may contain digits, hyphens, underscores, parentheses and square brackets. Other than that, there are no restrictions, and there is no implicit set of valid data types. The `type` values must begin with an alphabetic character and may contain digits, hyphens, underscores, parentheses and square brackets. The `name` values follow a similar format to `type`, but may start with an asterisk as another option to indicate an attribute is a primary key. Other than that, there are no restrictions, and there is no implicit set of valid data types.
#### Attribute Keys and Comments #### Attribute Keys and Comments

View File

@@ -154,11 +154,21 @@ describe('when parsing ER diagram it...', function () {
expect(entities[entity].attributes[2].attributeName).toBe('author-ref[name](1)'); expect(entities[entity].attributes[2].attributeName).toBe('author-ref[name](1)');
}); });
it('should allow asterisk at the start of title', function () { it('should allow asterisk at the start of attribute name', function () {
const entity = 'BOOK'; const entity = 'BOOK';
const attribute = 'string *title'; const attribute = 'string *title';
erDiagram.parser.parse(`erDiagram\n${entity}{${attribute}}`); erDiagram.parser.parse(`erDiagram\n${entity}{\n${attribute}}`);
const entities = erDb.getEntities();
expect(Object.keys(entities).length).toBe(1);
expect(entities[entity].attributes.length).toBe(1);
});
it('should allow asterisks at the start of attribute declared with type and name', () => {
const entity = 'BOOK';
const attribute = 'id *the_Primary_Key';
erDiagram.parser.parse(`erDiagram\n${entity} {\n${attribute}}`);
const entities = erDb.getEntities(); const entities = erDb.getEntities();
expect(Object.keys(entities).length).toBe(1); expect(Object.keys(entities).length).toBe(1);
expect(entities[entity].attributes.length).toBe(1); expect(entities[entity].attributes.length).toBe(1);

View File

@@ -142,7 +142,7 @@ erDiagram
} }
``` ```
The `type` and `name` values must begin with an alphabetic character and may contain digits, hyphens, underscores, parentheses and square brackets. Other than that, there are no restrictions, and there is no implicit set of valid data types. The `type` values must begin with an alphabetic character and may contain digits, hyphens, underscores, parentheses and square brackets. The `name` values follow a similar format to `type`, but may start with an asterisk as another option to indicate an attribute is a primary key. Other than that, there are no restrictions, and there is no implicit set of valid data types.
#### Attribute Keys and Comments #### Attribute Keys and Comments