File tree Expand file tree Collapse file tree 5 files changed +36
-12
lines changed Expand file tree Collapse file tree 5 files changed +36
-12
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export function fromMariaDB(ast, diagramDb = DB.GENERIC) {
2323 const tables = [ ] ;
2424 const relationships = [ ] ;
2525
26- ast . forEach ( ( e ) => {
26+ const parseSingleStatement = ( e ) => {
2727 if ( e . type === "create" ) {
2828 if ( e . keyword === "table" ) {
2929 const table = { } ;
@@ -250,7 +250,13 @@ export function fromMariaDB(ast, diagramDb = DB.GENERIC) {
250250 }
251251 } ) ;
252252 }
253- } ) ;
253+ } ;
254+
255+ if ( Array . isArray ( ast ) ) {
256+ ast . forEach ( ( e ) => parseSingleStatement ( e ) ) ;
257+ } else {
258+ parseSingleStatement ( ast ) ;
259+ }
254260
255261 relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
256262
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const affinity = {
99 ) ,
1010 [ DB . GENERIC ] : new Proxy (
1111 {
12- INT : "INTEGER " ,
12+ INTEGER : "INT " ,
1313 TINYINT : "SMALLINT" ,
1414 MEDIUMINT : "INTEGER" ,
1515 BIT : "BOOLEAN" ,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const affinity = {
99 ) ,
1010 [ DB . GENERIC ] : new Proxy (
1111 {
12- INT : "INTEGER " ,
12+ INTEGER : "INT " ,
1313 TINYINT : "SMALLINT" ,
1414 MEDIUMINT : "INTEGER" ,
1515 BIT : "BOOLEAN" ,
@@ -23,7 +23,7 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
2323 const tables = [ ] ;
2424 const relationships = [ ] ;
2525
26- ast . forEach ( ( e ) => {
26+ const parseSingleStatement = ( e ) => {
2727 if ( e . type === "create" ) {
2828 if ( e . keyword === "table" ) {
2929 const table = { } ;
@@ -250,7 +250,13 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
250250 }
251251 } ) ;
252252 }
253- } ) ;
253+ } ;
254+
255+ if ( Array . isArray ( ast ) ) {
256+ ast . forEach ( ( e ) => parseSingleStatement ( e ) ) ;
257+ } else {
258+ parseSingleStatement ( ast ) ;
259+ }
254260
255261 relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
256262
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const affinity = {
99 ) ,
1010 [ DB . GENERIC ] : new Proxy (
1111 {
12- INT : "INTEGER " ,
12+ INTEGER : "INT " ,
1313 MEDIUMINT : "INTEGER" ,
1414 BIT : "BOOLEAN" ,
1515 } ,
@@ -23,7 +23,7 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
2323 const types = [ ] ;
2424 const enums = [ ] ;
2525
26- ast . forEach ( ( e ) => {
26+ const parseSingleStatement = ( e ) => {
2727 if ( e . type === "create" ) {
2828 if ( e . keyword === "table" ) {
2929 const table = { } ;
@@ -315,7 +315,13 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
315315 }
316316 } ) ;
317317 }
318- } ) ;
318+ } ;
319+
320+ if ( Array . isArray ( ast ) ) {
321+ ast . forEach ( ( e ) => parseSingleStatement ( e ) ) ;
322+ } else {
323+ parseSingleStatement ( ast ) ;
324+ }
319325
320326 relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
321327
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const affinity = {
2323 ) ,
2424 [ DB . GENERIC ] : new Proxy (
2525 {
26- INT : "INTEGER " ,
26+ INTEGER : "INT " ,
2727 TINYINT : "SMALLINT" ,
2828 MEDIUMINT : "INTEGER" ,
2929 INT2 : "INTEGER" ,
@@ -40,7 +40,7 @@ export function fromSQLite(ast, diagramDb = DB.GENERIC) {
4040 const tables = [ ] ;
4141 const relationships = [ ] ;
4242
43- ast . forEach ( ( e ) => {
43+ const parseSingleStatement = ( e ) => {
4444 if ( e . type === "create" ) {
4545 if ( e . keyword === "table" ) {
4646 const table = { } ;
@@ -201,7 +201,13 @@ export function fromSQLite(ast, diagramDb = DB.GENERIC) {
201201 if ( found !== - 1 ) tables [ found ] . indices . forEach ( ( i , j ) => ( i . id = j ) ) ;
202202 }
203203 }
204- } ) ;
204+ } ;
205+
206+ if ( Array . isArray ( ast ) ) {
207+ ast . forEach ( ( e ) => parseSingleStatement ( e ) ) ;
208+ } else {
209+ parseSingleStatement ( ast ) ;
210+ }
205211
206212 relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
207213
You can’t perform that action at this time.
0 commit comments