Skip to content

Commit 9d68dd9

Browse files
committed
Fix foreign key comparison case sensitive
SQL keywords are case insensitive although they are often written in all caps. Object return from node-sql-parser is actually case sensitive based on the imported sql, thus "foreign key" doesn't work as expected.
1 parent 90f70a7 commit 9d68dd9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils/importSQL/mysql.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
105105
}
106106
});
107107
});
108-
} else if (d.constraint_type === "FOREIGN KEY") {
108+
} else if (d.constraint_type.toLowerCase() === "foreign key") {
109109
const relationship = {};
110110
const startTableId = table.id;
111111
const startTable = e.table[0].table;
@@ -187,7 +187,7 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
187187
e.expr.forEach((expr) => {
188188
if (
189189
expr.action === "add" &&
190-
expr.create_definitions.constraint_type === "FOREIGN KEY"
190+
expr.create_definitions.constraint_type.toLowerCase() === "foreign key"
191191
) {
192192
const relationship = {};
193193
const startTable = e.table[0].table;

0 commit comments

Comments
 (0)