Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Add support for comments on tables and columns in PostgreSQL import (#625)

Pranay Pandeyd3702ee48178
diff --git a/src/utils/importSQL/postgres.js b/src/utils/importSQL/postgres.js
index 2e741145..224a25d2 100644
--- a/src/utils/importSQL/postgres.js
+++ b/src/utils/importSQL/postgres.js
@@ -360,6 +360,23 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
}
});
}
+ } else if (e.type === "comment") {
+ if (e.target.type === "table") {
+ const table = tables.find((t) => t.name === e.target?.name?.table);
+ if (table) {
+ table.comment = e.expr.expr.value;
+ }
+ } else if (e.target.type === "column") {
+ const table = tables.find((t) => t.name === e.target?.name?.table);
+ if (table) {
+ const field = table.fields.find(
+ (f) => f.name === e.target?.name?.column?.expr?.value,
+ );
+ if (field) {
+ field.comment = e.expr.expr.value;
+ }
+ }
+ }
}
};