@@ -896,11 +896,11 @@ const generate_sql_ddl_1 = require("@funktechno/little-mermaid-2-the-sql/lib/src
896896const  sqlsimpleparser_1  =  require ( "@funktechno/sqlsimpleparser" ) ; 
897897/** 
898898 * SQL Tools Plugin for importing diagrams from SQL DDL and exporting to SQL. 
899-  * Version: 0.0.2  
899+  * Version: 0.0.3  
900900 */ 
901901Draw . loadPlugin ( function  ( ui )  { 
902902    // export sql methods 
903-     const  pluginVersion  =  "0.0.2 " ; 
903+     const  pluginVersion  =  "0.0.3 " ; 
904904    //Create Base div 
905905    const  divGenSQL  =  document . createElement ( "div" ) ; 
906906    divGenSQL . style . userSelect  =  "none" ; 
@@ -1043,14 +1043,14 @@ Draw.loadPlugin(function (ui) {
10431043                                                    // has to be one to many and not one to one 
10441044                                                    if  ( ( targetIsPrimary  ||  sourceIsPrimary )  && 
10451045                                                        ! ( targetIsPrimary  &&  sourceIsPrimary ) )  { 
1046-                                                         var  sourceId  =  edge . source . value ; 
1047-                                                         var  sourceAttr  =  getDbLabel ( sourceId ,  columnQuantifiers ) ; 
1046+                                                         let  sourceId  =  edge . source . value ; 
1047+                                                         const  sourceAttr  =  getDbLabel ( sourceId ,  columnQuantifiers ) ; 
10481048                                                        sourceId  =  sourceAttr . attributeName ; 
1049-                                                         var  sourceEntity  =  RemoveNameQuantifiers ( edge . source . parent . value ) ; 
1050-                                                         var  targetId  =  edge . target . value ; 
1051-                                                         var  targetAttr  =  getDbLabel ( targetId ,  columnQuantifiers ) ; 
1049+                                                         const  sourceEntity  =  RemoveNameQuantifiers ( edge . source . parent . value ) ; 
1050+                                                         let  targetId  =  edge . target . value ; 
1051+                                                         const  targetAttr  =  getDbLabel ( targetId ,  columnQuantifiers ) ; 
10521052                                                        targetId  =  targetAttr . attributeName ; 
1053-                                                         var  targetEntity  =  RemoveNameQuantifiers ( edge . target . parent . value ) ; 
1053+                                                         const  targetEntity  =  RemoveNameQuantifiers ( edge . target . parent . value ) ; 
10541054                                                        // entityA primary 
10551055                                                        // entityB foreign 
10561056                                                        const  relationship  =  { 
@@ -1067,23 +1067,23 @@ Draw.loadPlugin(function (ui) {
10671067                                                                `[${ targetEntity } ${ targetId } ${ sourceEntity } ${ sourceId }  
10681068                                                        } ; 
10691069                                                        // check that is doesn't already exist 
1070-                                                         var  exists  =  relationships . findIndex ( r  =>  r . entityA  ==  relationship . entityA  &&  r . entityB  ==  relationship . entityB  &&  r . roleA  ==  relationship . roleA ) ; 
1070+                                                         const  exists  =  relationships . findIndex ( r  =>  r . entityA  ==  relationship . entityA  &&  r . entityB  ==  relationship . entityB  &&  r . roleA  ==  relationship . roleA ) ; 
10711071                                                        if  ( exists  ==  - 1 )  { 
10721072                                                            relationships . push ( relationship ) ; 
10731073                                                        } 
10741074                                                    } 
10751075                                                    else  if  ( targetIsPrimary  &&  sourceIsPrimary )  { 
10761076                                                        // add a new many to many table 
1077-                                                         var  sourceId  =  edge . source . value ; 
1078-                                                         sourceAttr  =  getDbLabel ( sourceId ,  columnQuantifiers ) ; 
1077+                                                         let  sourceId  =  edge . source . value ; 
1078+                                                         const   sourceAttr  =  getDbLabel ( sourceId ,  columnQuantifiers ) ; 
10791079                                                        sourceAttr . attributeKeyType  =  "PK" ; 
10801080                                                        sourceId  =  sourceAttr . attributeName ; 
1081-                                                         var  sourceEntity  =  RemoveNameQuantifiers ( edge . source . parent . value ) ; 
1082-                                                         var  targetId  =  edge . target . value ; 
1083-                                                         targetAttr  =  getDbLabel ( targetId ,  columnQuantifiers ) ; 
1081+                                                         const  sourceEntity  =  RemoveNameQuantifiers ( edge . source . parent . value ) ; 
1082+                                                         let  targetId  =  edge . target . value ; 
1083+                                                         const   targetAttr  =  getDbLabel ( targetId ,  columnQuantifiers ) ; 
10841084                                                        targetAttr . attributeKeyType  =  "PK" ; 
10851085                                                        targetId  =  targetAttr . attributeName ; 
1086-                                                         var  targetEntity  =  RemoveNameQuantifiers ( edge . target . parent . value ) ; 
1086+                                                         const  targetEntity  =  RemoveNameQuantifiers ( edge . target . parent . value ) ; 
10871087                                                        const  compositeEntity  =  { 
10881088                                                            name : RemoveNameQuantifiers ( sourceEntity )  +  "_"  +  RemoveNameQuantifiers ( targetEntity ) , 
10891089                                                            attributes : [ sourceAttr ,  targetAttr ] 
@@ -1109,7 +1109,7 @@ Draw.loadPlugin(function (ui) {
11091109                                                            roleA : `[${ sourceEntity } ${ sourceId } ${ compositeEntity . name } ${ sourceId }  
11101110                                                        } ; 
11111111                                                        // check that is doesn't already exist 
1112-                                                         var  exists  =  relationships . findIndex ( r  =>  r . entityA  ==  relationship . entityA  &&  r . entityB  ==  relationship . entityB  &&  r . roleA  ==  relationship . roleA ) ; 
1112+                                                         let  exists  =  relationships . findIndex ( r  =>  r . entityA  ==  relationship . entityA  &&  r . entityB  ==  relationship . entityB  &&  r . roleA  ==  relationship . roleA ) ; 
11131113                                                        if  ( exists  ==  - 1 )  { 
11141114                                                            relationships . push ( relationship ) ; 
11151115                                                        } 
@@ -1179,7 +1179,7 @@ Draw.loadPlugin(function (ui) {
11791179        // update sql value in text area 
11801180        sqlInputGenSQL . value  =  sql ; 
11811181        // TODO: use selection as well? 
1182-         const  modelSelected  =  ui . editor . graph . getSelectionModel ( ) ; 
1182+         //  const modelSelected = ui.editor.graph.getSelectionModel();
11831183    } 
11841184    ; 
11851185    mxUtils . br ( divGenSQL ) ; 
@@ -1238,18 +1238,16 @@ Draw.loadPlugin(function (ui) {
12381238    divFromSQL . style . overflow  =  "hidden" ; 
12391239    divFromSQL . style . padding  =  "10px" ; 
12401240    divFromSQL . style . height  =  "100%" ; 
1241-     var  graph  =  ui . editor . graph ; 
12421241    const  sqlInputFromSQL  =  document . createElement ( "textarea" ) ; 
12431242    sqlInputFromSQL . style . height  =  "200px" ; 
12441243    sqlInputFromSQL . style . width  =  "100%" ; 
1245-     const  defaultReset  =  `/*\n\tDrawio default value\n\tPlugin: sql\n\tVersion: ${ pluginVersion } varchar (255),\n    " + 
1246-     "FirstName varchar (255),\n    Address varchar (255),\n    City varchar (255),\n    Primary Key(PersonID)\n);\n\n" +  
1244+     const  defaultReset  =  `/*\n\tDrawio default value\n\tPlugin: sql\n\tVersion: ${ pluginVersion } constchar (255),\n    " + 
1245+     "FirstName constchar (255),\n    Address constchar (255),\n    City constchar (255),\n    Primary Key(PersonID)\n);\n\n" +  
12471246    "CREATE TABLE Orders\n(\n    OrderID int NOT NULL PRIMARY KEY,\n    PersonID int NOT NULL,\n    FOREIGN KEY ([PersonID]) REFERENCES [Persons]([PersonID])" + 
12481247    "\n);` ; 
12491248    sqlInputFromSQL . value  =  defaultReset ; 
12501249    mxUtils . br ( divFromSQL ) ; 
12511250    divFromSQL . appendChild ( sqlInputFromSQL ) ; 
1252-     var  graph  =  ui . editor . graph ; 
12531251    // Extends Extras menu 
12541252    mxResources . parse ( "fromSql=From SQL" ) ; 
12551253    const  wndFromSQL  =  new  mxWindow ( mxResources . get ( "fromSql" ) ,  divFromSQL ,  document . body . offsetWidth  -  480 ,  140 ,  320 ,  320 ,  true ,  true ) ; 
@@ -1335,7 +1333,7 @@ Draw.loadPlugin(function (ui) {
13351333            // add foreign key edges 
13361334            const  model  =  graph . getModel ( ) ; 
13371335            const  columnQuantifiers  =  GetColumnQuantifiers ( type ) ; 
1338-             const  pt  =  graph . getFreeInsertPoint ( ) ; 
1336+             //  const pt = graph.getFreeInsertPoint();
13391337            foreignKeyList . forEach ( function  ( fk )  { 
13401338                if  ( fk . IsDestination  &&  fk . PrimaryKeyName  &&  fk . ReferencesPropertyName  && 
13411339                    fk . PrimaryKeyTableName  &&  fk . ReferencesTableName )  { 
@@ -1446,7 +1444,7 @@ Draw.loadPlugin(function (ui) {
14461444        } ; 
14471445    } 
14481446    if  ( theMenuExportAs  &&  ! window . VsCodeApi )  { 
1449-         var  oldMenuExportAs  =  theMenuExportAs . funct ; 
1447+         const  oldMenuExportAs  =  theMenuExportAs . funct ; 
14501448        theMenuExportAs . funct  =  function  ( ...args )  { 
14511449            const  [ menu ,  parent ]  =  args ; 
14521450            oldMenuExportAs . apply ( this ,  args ) ; 
@@ -1457,7 +1455,7 @@ Draw.loadPlugin(function (ui) {
14571455        // vscode file export sql menu 
14581456        const  menu  =  ui . menus . get ( "file" ) ; 
14591457        if  ( menu  &&  menu . enabled )  { 
1460-             var  oldMenuExportAs  =  menu . funct ; 
1458+             const  oldMenuExportAs  =  menu . funct ; 
14611459            menu . funct  =  function  ( ...args )  { 
14621460                const  [ menu ,  parent ]  =  args ; 
14631461                oldMenuExportAs . apply ( this ,  args ) ; 
0 commit comments