X-Git-Url: https://git.auder.net/doc/vendor/underscore-min.js?a=blobdiff_plain;f=parser.js;h=db70f7f282e074c415a990ac1ad422b6c2683624;hb=351d7a8448c574b40ed5d1cb488519d7b3f70ca5;hp=f718f316aa61b3528573a54e48629a3406c8219a;hpb=19addd10d9f37cc081779b9ec17f2f98ee161889;p=erdiag.git diff --git a/parser.js b/parser.js index f718f31..db70f7f 100644 --- a/parser.js +++ b/parser.js @@ -9,6 +9,9 @@ class ErDiags this.tables = { }; this.mcdParsing(description); this.mldParsing(); + + console.log(this.tables); + // Cache SVG graphs returned by server (in addition to server cache = good perfs) this.mcdGraph = ""; this.mldGraph = ""; @@ -192,7 +195,7 @@ class ErDiags isKey: e.card.length >= 2 && e.card[1] == 'R', //"weak tables" foreign keys become part of the key name: "#" + e2.name + "_" + attr.name, type: attr.type, - qualifiers: "foreign key references " + e2.name + " " + (e.card[0]=='1' : "not null" : ""), + qualifiers: "foreign key references " + e2.name + " " + (e.card[0]=='1' ? "not null" : ""), ref: e2.name, //easier drawMld function (fewer regexps) }); } @@ -202,18 +205,18 @@ class ErDiags else { // Add all keys in current entity - let fields = e.attributes.filter( attr => { return attr.isKey; }); + let fields = this.entities[e.name].attributes.filter( attr => { return attr.isKey; }); newTableAttrs.push({ fields: fields, entity: e.name, }); } - } + }); if (newTableAttrs.length > 1) { // Ok, really create a new table let newTable = { - name: a.name || newTableAttrs.map( item => { return item.entity; }).join("_"); + name: a.name || newTableAttrs.map( item => { return item.entity; }).join("_"), fields: [ ], }; newTableAttrs.forEach( item => { @@ -221,7 +224,7 @@ class ErDiags newTable.fields.push({ name: item.entity + "_" + f.name, isKey: true, - type: f.type,, + type: f.type, qualifiers: (f.qualifiers+" " || "") + "foreign key references " + item.entity + " not null", ref: item.entity, }); @@ -404,14 +407,14 @@ class ErDiags _.shuffle(Object.keys(this.tables)).forEach( name => { mldDot += '"' + name + '" [label=<
' + name + ' |
' + label + ' |