Skip to content

Fix invalid field indexes after import #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/EditorHeader/Modal/Modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ export default function Modal({
}

setModal(MODAL.NONE);
} catch {
} catch (e) {
console.log(e)
setError({
type: STATUS.ERROR,
message: `Please check for syntax errors or let us know about the error.`,
Expand Down
3 changes: 0 additions & 3 deletions src/utils/importSQL/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
}
});

table.fields.forEach((f, j) => {
f.id = j;
});
tables.push(table);
} else if (e.keyword === "index") {
const index = {
Expand Down
3 changes: 0 additions & 3 deletions src/utils/importSQL/oraclesql.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ export function fromOracleSQL(ast, diagramDb = DB.GENERIC) {
relationships.push(relationship);
}
});
table.fields.forEach((f, j) => {
f.id = j;
});
tables.push(table);
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/utils/importSQL/postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
),
)?.name;
if (!type && !dbToTypes[diagramDb][d.definition.dataType])
type = affinity[diagramDb][type];
field.type = type || d.definition.dataType;
type = affinity[diagramDb][d.definition.dataType.toUpperCase()];
field.type = type;

if (d.definition.expr && d.definition.expr.type === "expr_list") {
field.values = d.definition.expr.value.map((v) => v.value);
Expand Down Expand Up @@ -134,7 +134,9 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
);
if (!endField) return;

const startField = table.find((f) => f.name === startFieldName);
const startField = table.fields.find(
(f) => f.name === startFieldName,
);
if (!startField) return;

relationship.name = `fk_${startTableName}_${startFieldName}_${endTableName}`;
Expand Down Expand Up @@ -226,9 +228,6 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
relationships.forEach((r, i) => (r.id = i));
}
});
table.fields.forEach((f, j) => {
f.id = j;
});
tables.push(table);
} else if (e.keyword === "index") {
const index = {
Expand Down