From e513895060d1f5cf6d3195bcbde5d8a2abf710d1 Mon Sep 17 00:00:00 2001 From: Konuch Date: Tue, 17 Mar 2020 21:19:20 +0100 Subject: [PATCH] Export MySQL and MariaDB column comments. --- src/drivers/MysqlDriver.ts | 4 +++- src/models/Column.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/drivers/MysqlDriver.ts b/src/drivers/MysqlDriver.ts index a21df74..07b8d88 100644 --- a/src/drivers/MysqlDriver.ts +++ b/src/drivers/MysqlDriver.ts @@ -78,9 +78,10 @@ export default class MysqlDriver extends AbstractDriver { IsIdentity: number; COLUMN_TYPE: string; COLUMN_KEY: string; + COLUMN_COMMENT: string; }>(`SELECT TABLE_NAME,COLUMN_NAME,COLUMN_DEFAULT,IS_NULLABLE, DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,NUMERIC_PRECISION,NUMERIC_SCALE, - CASE WHEN EXTRA like '%auto_increment%' THEN 1 ELSE 0 END IsIdentity, COLUMN_TYPE, COLUMN_KEY + CASE WHEN EXTRA like '%auto_increment%' THEN 1 ELSE 0 END IsIdentity, COLUMN_TYPE, COLUMN_KEY, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA IN (${MysqlDriver.escapeCommaSeparatedList( dbNames )}) @@ -102,6 +103,7 @@ export default class MysqlDriver extends AbstractDriver { let columnType = resp.DATA_TYPE; if (resp.IS_NULLABLE === "YES") options.nullable = true; if (resp.COLUMN_KEY === "UNI") options.unique = true; + if (resp.COLUMN_COMMENT) options.comment = resp.COLUMN_COMMENT; if (resp.COLUMN_TYPE.endsWith(" unsigned")) options.unsigned = true; switch (resp.DATA_TYPE) { diff --git a/src/models/Column.ts b/src/models/Column.ts index f62271e..cc1e1f6 100644 --- a/src/models/Column.ts +++ b/src/models/Column.ts @@ -21,5 +21,6 @@ export type Column = { unsigned?: boolean; enum?: string[]; array?: boolean; // ? + comment?: string; }; };