Skip to content

Commit 965d1bb

Browse files
committed
allow for quoted enum/types to be correctly imported
used prettier for formatting as per contributing.md the type/enum check is case sensitive as there is no way I found to verify if the type was declared in quotes (case-sensitive) or without (to-lowercase by postgres)
1 parent 804a2a5 commit 965d1bb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/utils/importSQL/postgres.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
3838
if (d.resource === "column") {
3939
field.name = d.column.column.expr.value;
4040

41-
let type = types.find((t) => t.name === d.definition.dataType)?.name
42-
type ??= enums.find((t) => t.name === d.definition.dataType)?.name
41+
let type = types.find((t) =>
42+
new RegExp(`^(${t.name}|"${t.name}")$`).test(
43+
d.definition.dataType,
44+
),
45+
)?.name;
46+
type ??= enums.find((t) =>
47+
new RegExp(`^(${t.name}|"${t.name}")$`).test(
48+
d.definition.dataType,
49+
),
50+
)?.name;
4351
if (!type && !dbToTypes[diagramDb][type])
4452
type = affinity[diagramDb][type];
4553
field.type = type || d.definition.dataType;

0 commit comments

Comments
 (0)