🐛 add custom enums or types when importing from postgresql

no longer defaults to blob
This commit is contained in:
csc530 2024-10-11 19:30:28 -04:00
parent df54f864da
commit 804a2a5387
No known key found for this signature in database

View File

@ -38,11 +38,11 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
if (d.resource === "column") {
field.name = d.column.column.expr.value;
let type = d.definition.dataType;
if (!dbToTypes[diagramDb][type]) {
let type = types.find((t) => t.name === d.definition.dataType)?.name
type ??= enums.find((t) => t.name === d.definition.dataType)?.name
if (!type && !dbToTypes[diagramDb][type])
type = affinity[diagramDb][type];
}
field.type = type;
field.type = type || d.definition.dataType;
if (d.definition.expr && d.definition.expr.type === "expr_list") {
field.values = d.definition.expr.value.map((v) => v.value);