From 804a2a5387704a0b586db7b9ffb5ef873bc28043 Mon Sep 17 00:00:00 2001 From: csc530 <77406318+csc530@users.noreply.github.com> Date: Fri, 11 Oct 2024 19:30:28 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20add=20custom=20enums=20or=20type?= =?UTF-8?q?s=20when=20importing=20from=20postgresql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no longer defaults to blob --- src/utils/importSQL/postgres.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/importSQL/postgres.js b/src/utils/importSQL/postgres.js index 2912404c..13f5171c 100644 --- a/src/utils/importSQL/postgres.js +++ b/src/utils/importSQL/postgres.js @@ -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);