Fix import failing on single statements (#244)
This commit is contained in:
parent
f635d0774c
commit
b5e23fef20
@ -23,7 +23,7 @@ export function fromMariaDB(ast, diagramDb = DB.GENERIC) {
|
||||
const tables = [];
|
||||
const relationships = [];
|
||||
|
||||
ast.forEach((e) => {
|
||||
const parseSingleStatement = (e) => {
|
||||
if (e.type === "create") {
|
||||
if (e.keyword === "table") {
|
||||
const table = {};
|
||||
@ -250,7 +250,13 @@ export function fromMariaDB(ast, diagramDb = DB.GENERIC) {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (Array.isArray(ast)) {
|
||||
ast.forEach((e) => parseSingleStatement(e));
|
||||
} else {
|
||||
parseSingleStatement(ast);
|
||||
}
|
||||
|
||||
relationships.forEach((r, i) => (r.id = i));
|
||||
|
||||
|
@ -9,7 +9,7 @@ const affinity = {
|
||||
),
|
||||
[DB.GENERIC]: new Proxy(
|
||||
{
|
||||
INT: "INTEGER",
|
||||
INTEGER: "INT",
|
||||
TINYINT: "SMALLINT",
|
||||
MEDIUMINT: "INTEGER",
|
||||
BIT: "BOOLEAN",
|
||||
|
@ -9,7 +9,7 @@ const affinity = {
|
||||
),
|
||||
[DB.GENERIC]: new Proxy(
|
||||
{
|
||||
INT: "INTEGER",
|
||||
INTEGER: "INT",
|
||||
TINYINT: "SMALLINT",
|
||||
MEDIUMINT: "INTEGER",
|
||||
BIT: "BOOLEAN",
|
||||
@ -23,7 +23,7 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
|
||||
const tables = [];
|
||||
const relationships = [];
|
||||
|
||||
ast.forEach((e) => {
|
||||
const parseSingleStatement = (e) => {
|
||||
if (e.type === "create") {
|
||||
if (e.keyword === "table") {
|
||||
const table = {};
|
||||
@ -250,7 +250,13 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (Array.isArray(ast)) {
|
||||
ast.forEach((e) => parseSingleStatement(e));
|
||||
} else {
|
||||
parseSingleStatement(ast);
|
||||
}
|
||||
|
||||
relationships.forEach((r, i) => (r.id = i));
|
||||
|
||||
|
@ -9,7 +9,7 @@ const affinity = {
|
||||
),
|
||||
[DB.GENERIC]: new Proxy(
|
||||
{
|
||||
INT: "INTEGER",
|
||||
INTEGER: "INT",
|
||||
MEDIUMINT: "INTEGER",
|
||||
BIT: "BOOLEAN",
|
||||
},
|
||||
@ -23,7 +23,7 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
|
||||
const types = [];
|
||||
const enums = [];
|
||||
|
||||
ast.forEach((e) => {
|
||||
const parseSingleStatement = (e) => {
|
||||
if (e.type === "create") {
|
||||
if (e.keyword === "table") {
|
||||
const table = {};
|
||||
@ -315,7 +315,13 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (Array.isArray(ast)) {
|
||||
ast.forEach((e) => parseSingleStatement(e));
|
||||
} else {
|
||||
parseSingleStatement(ast);
|
||||
}
|
||||
|
||||
relationships.forEach((r, i) => (r.id = i));
|
||||
|
||||
|
@ -23,7 +23,7 @@ const affinity = {
|
||||
),
|
||||
[DB.GENERIC]: new Proxy(
|
||||
{
|
||||
INT: "INTEGER",
|
||||
INTEGER: "INT",
|
||||
TINYINT: "SMALLINT",
|
||||
MEDIUMINT: "INTEGER",
|
||||
INT2: "INTEGER",
|
||||
@ -40,7 +40,7 @@ export function fromSQLite(ast, diagramDb = DB.GENERIC) {
|
||||
const tables = [];
|
||||
const relationships = [];
|
||||
|
||||
ast.forEach((e) => {
|
||||
const parseSingleStatement = (e) => {
|
||||
if (e.type === "create") {
|
||||
if (e.keyword === "table") {
|
||||
const table = {};
|
||||
@ -201,7 +201,13 @@ export function fromSQLite(ast, diagramDb = DB.GENERIC) {
|
||||
if (found !== -1) tables[found].indices.forEach((i, j) => (i.id = j));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (Array.isArray(ast)) {
|
||||
ast.forEach((e) => parseSingleStatement(e));
|
||||
} else {
|
||||
parseSingleStatement(ast);
|
||||
}
|
||||
|
||||
relationships.forEach((r, i) => (r.id = i));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user