Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Fix corrupted endFieldIds after import

1ilit9fd682ccdc35
diff --git a/src/utils/importSQL/mariadb.js b/src/utils/importSQL/mariadb.js
index 77461755..563200ef 100644
--- a/src/utils/importSQL/mariadb.js
+++ b/src/utils/importSQL/mariadb.js
@@ -119,7 +119,7 @@ export function fromMariaDB(ast, diagramDb = DB.GENERIC) {
const endFieldId = tables[endTableId].fields.findIndex(
(f) => f.name === endField,
);
- if (endField === -1) return;
+ if (endFieldId === -1) return;
const startFieldId = table.fields.findIndex(
(f) => f.name === startField,
@@ -223,7 +223,7 @@ export function fromMariaDB(ast, diagramDb = DB.GENERIC) {
const endFieldId = tables[endTableId].fields.findIndex(
(f) => f.name === endField,
);
- if (endField === -1) return;
+ if (endFieldId === -1) return;
const startFieldId = tables[startTableId].fields.findIndex(
(f) => f.name === startField,
diff --git a/src/utils/importSQL/mssql.js b/src/utils/importSQL/mssql.js
index bb7a95e5..740f7441 100644
--- a/src/utils/importSQL/mssql.js
+++ b/src/utils/importSQL/mssql.js
@@ -131,7 +131,7 @@ export function fromMSSQL(ast, diagramDb = DB.GENERIC) {
const endFieldId = tables[endTableId].fields.findIndex(
(f) => f.name === endField,
);
- if (endField === -1) return;
+ if (endFieldId === -1) return;
const startFieldId = table.fields.findIndex(
(f) => f.name === startField,
@@ -235,7 +235,7 @@ export function fromMSSQL(ast, diagramDb = DB.GENERIC) {
const endFieldId = tables[endTableId].fields.findIndex(
(f) => f.name === endField,
);
- if (endField === -1) return;
+ if (endFieldId === -1) return;
const startFieldId = tables[startTableId].fields.findIndex(
(f) => f.name === startField,
diff --git a/src/utils/importSQL/mysql.js b/src/utils/importSQL/mysql.js
index e8297273..f8b37151 100644
--- a/src/utils/importSQL/mysql.js
+++ b/src/utils/importSQL/mysql.js
@@ -119,7 +119,7 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
const endFieldId = tables[endTableId].fields.findIndex(
(f) => f.name === endField,
);
- if (endField === -1) return;
+ if (endFieldId === -1) return;
const startFieldId = table.fields.findIndex(
(f) => f.name === startField,
@@ -223,7 +223,7 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
const endFieldId = tables[endTableId].fields.findIndex(
(f) => f.name === endField,
);
- if (endField === -1) return;
+ if (endFieldId === -1) return;
const startFieldId = tables[startTableId].fields.findIndex(
(f) => f.name === startField,
diff --git a/src/utils/importSQL/sqlite.js b/src/utils/importSQL/sqlite.js
index f2792198..5bd3a1bd 100644
--- a/src/utils/importSQL/sqlite.js
+++ b/src/utils/importSQL/sqlite.js
@@ -136,7 +136,7 @@ export function fromSQLite(ast, diagramDb = DB.GENERIC) {
const endFieldId = tables[endTableId].fields.findIndex(
(f) => f.name === endField,
);
- if (endField === -1) return;
+ if (endFieldId === -1) return;
const startFieldId = table.fields.findIndex(
(f) => f.name === startField,