From 9983403e676ef78176ac471107f1513ee2537af7 Mon Sep 17 00:00:00 2001 From: Jose Varela Date: Wed, 24 May 2023 21:21:29 +0100 Subject: [PATCH] Retrieve `collation` on `columnInfo` for MySQL --- lib/dialects/mysql.ts | 1 + lib/types/column.ts | 3 +++ test/mysql.spec.ts | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/lib/dialects/mysql.ts b/lib/dialects/mysql.ts index eaebde0..a313e5d 100644 --- a/lib/dialects/mysql.ts +++ b/lib/dialects/mysql.ts @@ -58,6 +58,7 @@ export function rawColumnToColumn(rawColumn: RawColumn): Column { foreign_key_column: rawColumn.REFERENCED_COLUMN_NAME, foreign_key_table: rawColumn.REFERENCED_TABLE_NAME, comment: rawColumn.COLUMN_COMMENT, + collation: rawColumn.COLLATION_NAME, }; } diff --git a/lib/types/column.ts b/lib/types/column.ts index 04412c4..03adf6f 100644 --- a/lib/types/column.ts +++ b/lib/types/column.ts @@ -22,4 +22,7 @@ export interface Column { // Postgres Only schema?: string; foreign_key_schema?: string | null; + + // MySQL only + collation?: string | null; } diff --git a/test/mysql.spec.ts b/test/mysql.spec.ts index 8798b5c..36553ea 100644 --- a/test/mysql.spec.ts +++ b/test/mysql.spec.ts @@ -139,6 +139,7 @@ describe('mysql', () => { foreign_key_column: 'id', foreign_key_table: 'teams', comment: '', + collation: null, }, { name: 'id', @@ -157,6 +158,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: null, }, { name: 'uuid', @@ -175,6 +177,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'id', @@ -193,6 +196,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: null, }, { name: 'request_path', @@ -211,6 +215,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'user_agent', @@ -229,6 +234,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'created_at', @@ -247,6 +253,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: null, }, { name: 'name', @@ -265,6 +272,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'name_upper', @@ -283,6 +291,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'description', @@ -301,6 +310,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'credits', @@ -319,6 +329,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: 'Remaining usage credits', + collation: null, }, { name: 'created_at', @@ -337,6 +348,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: null, }, { name: 'activated_at', @@ -355,6 +367,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: null, }, { name: 'email', @@ -373,6 +386,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'password', @@ -391,6 +405,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'status', @@ -409,6 +424,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, ]); }); @@ -432,6 +448,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: null, }, { name: 'uuid', @@ -450,6 +467,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'name', @@ -468,6 +486,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'name_upper', @@ -486,6 +505,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'description', @@ -504,6 +524,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }, { name: 'credits', @@ -522,6 +543,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: 'Remaining usage credits', + collation: null, }, { name: 'created_at', @@ -540,6 +562,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: null, }, { name: 'activated_at', @@ -558,6 +581,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: null, }, ]); }); @@ -580,6 +604,7 @@ describe('mysql', () => { foreign_key_column: null, foreign_key_table: null, comment: '', + collation: 'latin1_swedish_ci', }); }); });