mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-05-23 17:59:19 +00:00
Fix import from sql for mssql
This commit is contained in:
parent
5476470aa7
commit
f0adcf1a25
8
package-lock.json
generated
8
package-lock.json
generated
@ -28,7 +28,7 @@
|
||||
"jsonschema": "^1.4.1",
|
||||
"jspdf": "^2.5.1",
|
||||
"lexical": "^0.12.5",
|
||||
"node-sql-parser": "^5.3.4",
|
||||
"node-sql-parser": "^5.3.6",
|
||||
"octokit": "^4.0.2",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
@ -4835,9 +4835,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/node-sql-parser": {
|
||||
"version": "5.3.4",
|
||||
"resolved": "https://registry.npmjs.org/node-sql-parser/-/node-sql-parser-5.3.4.tgz",
|
||||
"integrity": "sha512-uOgTAADMc4pMjKGkSPELkQUoYAlQBz+JqC9zw/MFs7/wr0fkYoxkexB3sNjslnPttlJlxiaseHFQ36xsXhmnUQ==",
|
||||
"version": "5.3.6",
|
||||
"resolved": "https://registry.npmjs.org/node-sql-parser/-/node-sql-parser-5.3.6.tgz",
|
||||
"integrity": "sha512-TXak4rIvmpL7Ap1BJQGfAGewoELQGZ/Rf9YYt9rKz73ykDp3HNnXT08jDFC/8FjqiPoRxcPNVecSwTmjz7LrFA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@types/pegjs": "^0.10.0",
|
||||
|
@ -30,7 +30,7 @@
|
||||
"jsonschema": "^1.4.1",
|
||||
"jspdf": "^2.5.1",
|
||||
"lexical": "^0.12.5",
|
||||
"node-sql-parser": "^5.3.4",
|
||||
"node-sql-parser": "^5.3.6",
|
||||
"octokit": "^4.0.2",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
|
@ -199,7 +199,8 @@ export function fromMSSQL(ast, diagramDb = DB.GENERIC) {
|
||||
e.expr.forEach((expr) => {
|
||||
if (
|
||||
expr.action === "add" &&
|
||||
expr.create_definitions.constraint_type.toLowerCase() === "foreign key"
|
||||
expr.create_definitions.constraint_type.toLowerCase() ===
|
||||
"foreign key"
|
||||
) {
|
||||
const relationship = {};
|
||||
const startTable = e.table[0].table;
|
||||
@ -266,16 +267,18 @@ export function fromMSSQL(ast, diagramDb = DB.GENERIC) {
|
||||
|
||||
if (ast.go_next) {
|
||||
let x = { ...ast };
|
||||
let done = Array.isArray(x.go_next);
|
||||
let done = false;
|
||||
while (!done) {
|
||||
parseSingleStatement(x.ast);
|
||||
done = Array.isArray(x.go_next) && x.go_next.length === 0;
|
||||
x = { ...x.go_next };
|
||||
done = Array.isArray(x.go_next);
|
||||
}
|
||||
} else if (Array.isArray(ast)) {
|
||||
ast.forEach((e) => {
|
||||
parseSingleStatement(e);
|
||||
});
|
||||
} else if (typeof ast === "object") {
|
||||
parseSingleStatement(ast);
|
||||
}
|
||||
|
||||
return { tables, relationships };
|
||||
|
Loading…
Reference in New Issue
Block a user