Skip to content

Commit d3702ee

Browse files
Add support for comments on tables and columns in PostgreSQL import (#625)
1 parent ae7667b commit d3702ee

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/utils/importSQL/postgres.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,23 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
360360
}
361361
});
362362
}
363+
} else if (e.type === "comment") {
364+
if (e.target.type === "table") {
365+
const table = tables.find((t) => t.name === e.target?.name?.table);
366+
if (table) {
367+
table.comment = e.expr.expr.value;
368+
}
369+
} else if (e.target.type === "column") {
370+
const table = tables.find((t) => t.name === e.target?.name?.table);
371+
if (table) {
372+
const field = table.fields.find(
373+
(f) => f.name === e.target?.name?.column?.expr?.value,
374+
);
375+
if (field) {
376+
field.comment = e.expr.expr.value;
377+
}
378+
}
379+
}
363380
}
364381
};
365382

0 commit comments

Comments
 (0)