Skip to content

Commit

Permalink
Fix foreign key comparison case sensitive
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ruizhii committed Oct 27, 2024
1 parent 90f70a7 commit 9d68dd9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/importSQL/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
}
});
});
} else if (d.constraint_type === "FOREIGN KEY") {
} else if (d.constraint_type.toLowerCase() === "foreign key") {
const relationship = {};
const startTableId = table.id;
const startTable = e.table[0].table;
Expand Down Expand Up @@ -187,7 +187,7 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
e.expr.forEach((expr) => {
if (
expr.action === "add" &&
expr.create_definitions.constraint_type === "FOREIGN KEY"
expr.create_definitions.constraint_type.toLowerCase() === "foreign key"
) {
const relationship = {};
const startTable = e.table[0].table;
Expand Down

0 comments on commit 9d68dd9

Please sign in to comment.