From 2b31804447de69e23534ecf01a5ef60407d5c3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1r=20=C3=96rlygsson?= Date: Sat, 20 Feb 2021 21:23:37 +0000 Subject: [PATCH] Rename selected columns to guarantee correct case (#7) Fixes a column-name issue that seems to affect mysql@8 See description/info here: https://github.com/SweetIQ/schemats/issues/97 --- src/mysql-client.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mysql-client.ts b/src/mysql-client.ts index b60c1a2..e1c7877 100644 --- a/src/mysql-client.ts +++ b/src/mysql-client.ts @@ -72,7 +72,7 @@ export class MySQL { private async tableNames(): Promise { const schemaTables = await query( this.connection, - sql`SELECT table_name + sql`SELECT table_name as table_name FROM information_schema.columns WHERE table_schema = ${this.schema()} GROUP BY table_name @@ -90,7 +90,10 @@ export class MySQL { const rawEnumRecords = await query( this.connection, - sql`SELECT column_name, column_type, data_type + sql`SELECT + column_name as column_name, + column_type as column_type, + data_type as data_type FROM information_schema.columns WHERE data_type IN ('enum', 'set') AND table_schema = ${this.schema()} @@ -111,7 +114,12 @@ export class MySQL { const tableColumns = await query( this.connection, - sql`SELECT column_name, data_type, is_nullable, column_default, column_comment + sql`SELECT + column_name as column_name, + data_type as data_type, + is_nullable as is_nullable, + column_default as column_default, + column_comment as column_comment FROM information_schema.columns WHERE table_name = ${tableName} AND table_schema = ${tableSchema}`