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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #3019 Add word boundary to FK&PK. #3168

Merged
merged 1 commit into from Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/diagrams/er/parser/erDiagram.jison
Expand Up @@ -28,7 +28,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
"erDiagram" return 'ER_DIAGRAM';
"{" { this.begin("block"); return 'BLOCK_START'; }
<block>\s+ /* skip whitespace in block */
<block>(?:PK)|(?:FK) return 'ATTRIBUTE_KEY'
<block>\b((?:PK)|(?:FK))\b return 'ATTRIBUTE_KEY'
mmorel-35 marked this conversation as resolved.
Show resolved Hide resolved
<block>[A-Za-z][A-Za-z0-9\-_]* return 'ATTRIBUTE_WORD'
<block>\"[^"]*\" return 'COMMENT';
<block>[\n]+ /* nothing */
Expand Down
13 changes: 13 additions & 0 deletions src/diagrams/er/parser/erDiagram.spec.js
Expand Up @@ -72,6 +72,19 @@ describe('when parsing ER diagram it...', function () {
expect(entities[entity].attributes.length).toBe(1);
});

it('should allow an entity with attribute starting with fk or pk and a comment', function () {
const entity = 'BOOK';
const attribute1 = 'int fk_title FK';
const attribute2 = 'string pk_author PK';
const attribute3 = 'float pk_price PK "comment"';

erDiagram.parser.parse(
`erDiagram\n${entity} {\n${attribute1} \n\n${attribute2}\n${attribute3}\n}`
);
const entities = erDb.getEntities();
expect(entities[entity].attributes.length).toBe(3);
});

it('should allow an entity with multiple attributes to be defined', function () {
const entity = 'BOOK';
const attribute1 = 'string title';
Expand Down