diff --git a/demos/er.html b/demos/er.html
index 634a8f9e5..662b8cbed 100644
--- a/demos/er.html
+++ b/demos/er.html
@@ -75,7 +75,7 @@
erDiagram
"HOSPITAL" {
int id PK
- int doctor_id PK,FK
+ int doctor_id PK, FK
string address UK
string name
string phone_number
@@ -103,7 +103,7 @@
int age
}
NAMED-DRIVER {
- string carRegistrationNumber PK,FK
+ string carRegistrationNumber PK, FK
string driverLicence PK,FK
}
MANUFACTURER only one to zero or more CAR : makes
diff --git a/docs/syntax/entityRelationshipDiagram.md b/docs/syntax/entityRelationshipDiagram.md
index f06af0c0b..9fa5fa517 100644
--- a/docs/syntax/entityRelationshipDiagram.md
+++ b/docs/syntax/entityRelationshipDiagram.md
@@ -200,7 +200,7 @@ The `type` and `name` values must begin with an alphabetic character and may con
#### Attribute Keys and Comments
-Attributes may also have a `key` or comment defined. Keys can be `PK`, `FK` or `UK`, for Primary Key, Foreign Key or Unique Key. To specify multiple key constraints on a single attribute, separate them with a comma (e.g., `PK,FK`).. A `comment` is defined by double quotes at the end of an attribute. Comments themselves cannot have double-quote characters in them.
+Attributes may also have a `key` or comment defined. Keys can be `PK`, `FK` or `UK`, for Primary Key, Foreign Key or Unique Key. To specify multiple key constraints on a single attribute, separate them with a comma (e.g., `PK, FK`).. A `comment` is defined by double quotes at the end of an attribute. Comments themselves cannot have double-quote characters in them.
```mermaid-example
erDiagram
@@ -220,8 +220,8 @@ erDiagram
int age
}
NAMED-DRIVER {
- string carRegistrationNumber PK,FK
- string driverLicence PK,FK
+ string carRegistrationNumber PK, FK
+ string driverLicence PK, FK
}
MANUFACTURER only one to zero or more CAR : makes
```
@@ -244,8 +244,8 @@ erDiagram
int age
}
NAMED-DRIVER {
- string carRegistrationNumber PK,FK
- string driverLicence PK,FK
+ string carRegistrationNumber PK, FK
+ string driverLicence PK, FK
}
MANUFACTURER only one to zero or more CAR : makes
```
diff --git a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js
index 2a8f1a28b..40ec28ada 100644
--- a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js
+++ b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js
@@ -191,19 +191,25 @@ describe('when parsing ER diagram it...', function () {
});
it('should allow an entity with attributes that have many constraints and comments', function () {
- const entity = 'BOOK';
- const attribute1 = 'int customer_number PK,FK "comment"';
- const attribute2 = 'datetime customer_status_start_datetime PK,UK';
- const attribute3 = 'string customer_name';
+ const entity = 'CUSTOMER';
+ const attribute1 = 'int customer_number PK, FK "comment1"';
+ const attribute2 = 'datetime customer_status_start_datetime PK,UK, FK';
+ const attribute3 = 'datetime customer_status_end_datetime PK , UK "comment3"';
+ const attribute4 = 'string customer_firstname';
+ const attribute5 = 'string customer_lastname "comment5"';
erDiagram.parser.parse(
- `erDiagram\n${entity} {\n${attribute1} \n\n${attribute2}\n${attribute3}\n}`
+ `erDiagram\n${entity} {\n${attribute1}\n${attribute2}\n${attribute3}\n${attribute4}\n${attribute5}\n}`
);
const entities = erDb.getEntities();
expect(entities[entity].attributes[0].attributeKeyTypeList).toEqual(['PK', 'FK']);
- expect(entities[entity].attributes[0].attributeComment).toBe('comment');
- expect(entities[entity].attributes[1].attributeKeyTypeList).toEqual(['PK', 'UK']);
- expect(entities[entity].attributes[2].attributeKeyTypeList).toBeUndefined();
+ expect(entities[entity].attributes[0].attributeComment).toBe('comment1');
+ expect(entities[entity].attributes[1].attributeKeyTypeList).toEqual(['PK', 'UK', 'FK']);
+ expect(entities[entity].attributes[2].attributeKeyTypeList).toEqual(['PK', 'UK']);
+ expect(entities[entity].attributes[2].attributeComment).toBe('comment3');
+ expect(entities[entity].attributes[3].attributeKeyTypeList).toBeUndefined();
+ expect(entities[entity].attributes[4].attributeKeyTypeList).toBeUndefined();
+ expect(entities[entity].attributes[4].attributeComment).toBe('comment5');
});
it('should allow an entity with attribute that has a generic type', function () {
diff --git a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md
index abce89467..7067a65d9 100644
--- a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md
+++ b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md
@@ -146,7 +146,7 @@ The `type` and `name` values must begin with an alphabetic character and may con
#### Attribute Keys and Comments
-Attributes may also have a `key` or comment defined. Keys can be `PK`, `FK` or `UK`, for Primary Key, Foreign Key or Unique Key. To specify multiple key constraints on a single attribute, separate them with a comma (e.g., `PK,FK`).. A `comment` is defined by double quotes at the end of an attribute. Comments themselves cannot have double-quote characters in them.
+Attributes may also have a `key` or comment defined. Keys can be `PK`, `FK` or `UK`, for Primary Key, Foreign Key or Unique Key. To specify multiple key constraints on a single attribute, separate them with a comma (e.g., `PK, FK`).. A `comment` is defined by double quotes at the end of an attribute. Comments themselves cannot have double-quote characters in them.
```mermaid-example
erDiagram
@@ -166,8 +166,8 @@ erDiagram
int age
}
NAMED-DRIVER {
- string carRegistrationNumber PK,FK
- string driverLicence PK,FK
+ string carRegistrationNumber PK, FK
+ string driverLicence PK, FK
}
MANUFACTURER only one to zero or more CAR : makes
```