Fix invalid field indexes after import (#466)

* Fix invalid field indexes after import

* fix postgres types
This commit is contained in:
1ilit
2025-05-28 04:18:11 +04:00
committed by GitHub
parent 89d4c29076
commit f2d60a70e0
4 changed files with 7 additions and 13 deletions

View File

@@ -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.`,

View File

@@ -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 = {

View File

@@ -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);
}
}

View File

@@ -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);
@@ -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}`;
@@ -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 = {