X-Git-Url: https://git.auder.net/assets/img/current/git-favicon.png?a=blobdiff_plain;f=parser.js;h=6d028fd05e07e5f812a4a0238f13dbce54aa30ef;hb=0133e929ace3b602f7e280b5a8ed119836dc8172;hp=f41a755ef87dc3ab7b933aa0bad911a866d3b25e;hpb=5fe4fa10fa947c09ae37841bad3bc76e5767fa0b;p=erdiag.git diff --git a/parser.js b/parser.js index f41a755..6d028fd 100644 --- a/parser.js +++ b/parser.js @@ -94,7 +94,7 @@ class ErDiags { let field = { }; let line = lines[i]; - if (line.charAt(0) == '#') + if (line.charAt(0) == '+') { field.isKey = true; line = line.slice(1); @@ -192,9 +192,11 @@ class ErDiags // Pass 2: parse associations, add foreign keys when cardinality is 0,1 or 1,1 this.associations.forEach( a => { let newTableAttrs = [ ]; + let hasZeroOne = false; a.entities.forEach( e => { if (['?','1'].includes(e.card[0])) { + hasZeroOne = true; // Foreign key apparition (for each entity in association minus current one, for each identifying attribute) a.entities.forEach( e2 => { if (e2.name == e.name) @@ -223,7 +225,7 @@ class ErDiags }); } }); - if (newTableAttrs.length > 1) + if (!hasZeroOne && newTableAttrs.length > 1) { // Ok, really create a new table let newTable = {