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) {
23
23
const tables = [ ] ;
24
24
const relationships = [ ] ;
25
25
26
- ast . forEach ( ( e ) => {
26
+ const parseSingleStatement = ( e ) => {
27
27
if ( e . type === "create" ) {
28
28
if ( e . keyword === "table" ) {
29
29
const table = { } ;
@@ -250,7 +250,13 @@ export function fromMariaDB(ast, diagramDb = DB.GENERIC) {
250
250
}
251
251
} ) ;
252
252
}
253
- } ) ;
253
+ } ;
254
+
255
+ if ( Array . isArray ( ast ) ) {
256
+ ast . forEach ( ( e ) => parseSingleStatement ( e ) ) ;
257
+ } else {
258
+ parseSingleStatement ( ast ) ;
259
+ }
254
260
255
261
relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
256
262
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const affinity = {
9
9
) ,
10
10
[ DB . GENERIC ] : new Proxy (
11
11
{
12
- INT : "INTEGER " ,
12
+ INTEGER : "INT " ,
13
13
TINYINT : "SMALLINT" ,
14
14
MEDIUMINT : "INTEGER" ,
15
15
BIT : "BOOLEAN" ,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const affinity = {
9
9
) ,
10
10
[ DB . GENERIC ] : new Proxy (
11
11
{
12
- INT : "INTEGER " ,
12
+ INTEGER : "INT " ,
13
13
TINYINT : "SMALLINT" ,
14
14
MEDIUMINT : "INTEGER" ,
15
15
BIT : "BOOLEAN" ,
@@ -23,7 +23,7 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
23
23
const tables = [ ] ;
24
24
const relationships = [ ] ;
25
25
26
- ast . forEach ( ( e ) => {
26
+ const parseSingleStatement = ( e ) => {
27
27
if ( e . type === "create" ) {
28
28
if ( e . keyword === "table" ) {
29
29
const table = { } ;
@@ -250,7 +250,13 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
250
250
}
251
251
} ) ;
252
252
}
253
- } ) ;
253
+ } ;
254
+
255
+ if ( Array . isArray ( ast ) ) {
256
+ ast . forEach ( ( e ) => parseSingleStatement ( e ) ) ;
257
+ } else {
258
+ parseSingleStatement ( ast ) ;
259
+ }
254
260
255
261
relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
256
262
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const affinity = {
9
9
) ,
10
10
[ DB . GENERIC ] : new Proxy (
11
11
{
12
- INT : "INTEGER " ,
12
+ INTEGER : "INT " ,
13
13
MEDIUMINT : "INTEGER" ,
14
14
BIT : "BOOLEAN" ,
15
15
} ,
@@ -23,7 +23,7 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
23
23
const types = [ ] ;
24
24
const enums = [ ] ;
25
25
26
- ast . forEach ( ( e ) => {
26
+ const parseSingleStatement = ( e ) => {
27
27
if ( e . type === "create" ) {
28
28
if ( e . keyword === "table" ) {
29
29
const table = { } ;
@@ -315,7 +315,13 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
315
315
}
316
316
} ) ;
317
317
}
318
- } ) ;
318
+ } ;
319
+
320
+ if ( Array . isArray ( ast ) ) {
321
+ ast . forEach ( ( e ) => parseSingleStatement ( e ) ) ;
322
+ } else {
323
+ parseSingleStatement ( ast ) ;
324
+ }
319
325
320
326
relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
321
327
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const affinity = {
23
23
) ,
24
24
[ DB . GENERIC ] : new Proxy (
25
25
{
26
- INT : "INTEGER " ,
26
+ INTEGER : "INT " ,
27
27
TINYINT : "SMALLINT" ,
28
28
MEDIUMINT : "INTEGER" ,
29
29
INT2 : "INTEGER" ,
@@ -40,7 +40,7 @@ export function fromSQLite(ast, diagramDb = DB.GENERIC) {
40
40
const tables = [ ] ;
41
41
const relationships = [ ] ;
42
42
43
- ast . forEach ( ( e ) => {
43
+ const parseSingleStatement = ( e ) => {
44
44
if ( e . type === "create" ) {
45
45
if ( e . keyword === "table" ) {
46
46
const table = { } ;
@@ -201,7 +201,13 @@ export function fromSQLite(ast, diagramDb = DB.GENERIC) {
201
201
if ( found !== - 1 ) tables [ found ] . indices . forEach ( ( i , j ) => ( i . id = j ) ) ;
202
202
}
203
203
}
204
- } ) ;
204
+ } ;
205
+
206
+ if ( Array . isArray ( ast ) ) {
207
+ ast . forEach ( ( e ) => parseSingleStatement ( e ) ) ;
208
+ } else {
209
+ parseSingleStatement ( ast ) ;
210
+ }
205
211
206
212
relationships . forEach ( ( r , i ) => ( r . id = i ) ) ;
207
213
You can’t perform that action at this time.
0 commit comments