Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX #259] use custom types when importing from postgresql #261

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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)
  • Loading branch information
csc530 committed Oct 12, 2024
commit 965d1bb1454523a909590843cd2d96a58b3cb068
12 changes: 10 additions & 2 deletions src/utils/importSQL/postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ 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
Loading