Skip to content

Commit

Permalink
allow for quoted enum/types to be correctly imported
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
csc530 committed Oct 12, 2024
1 parent 804a2a5 commit f3d6219
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/importSQL/postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
if (d.resource === "column") {
field.name = d.column.column.expr.value;

let type = types.find((t) => t.name === d.definition.dataType)?.name
type ??= enums.find((t) => t.name === d.definition.dataType)?.name
let type = types.find((t) => new RegExp(`^(${t.name}|"${t.name}")$`).test(d.definition.dataType))?.name;
type ??= enums.find((t) => new RegExp(`^(${t.name}|"${t.name}")$`).test(d.definition.dataType))?.name;
if (!type && !dbToTypes[diagramDb][type])
type = affinity[diagramDb][type];
field.type = type || d.definition.dataType;
Expand Down

0 comments on commit f3d6219

Please sign in to comment.