Skip to content

Commit 2b31804

Browse files
authored
Rename selected columns to guarantee correct case (#7)
Fixes a column-name issue that seems to affect mysql@8 See description/info here: SweetIQ/schemats#97
1 parent 711b641 commit 2b31804

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/mysql-client.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class MySQL {
7272
private async tableNames(): Promise<string[]> {
7373
const schemaTables = await query<TableType>(
7474
this.connection,
75-
sql`SELECT table_name
75+
sql`SELECT table_name as table_name
7676
FROM information_schema.columns
7777
WHERE table_schema = ${this.schema()}
7878
GROUP BY table_name
@@ -90,7 +90,10 @@ export class MySQL {
9090

9191
const rawEnumRecords = await query<EnumRecord>(
9292
this.connection,
93-
sql`SELECT column_name, column_type, data_type
93+
sql`SELECT
94+
column_name as column_name,
95+
column_type as column_type,
96+
data_type as data_type
9497
FROM information_schema.columns
9598
WHERE data_type IN ('enum', 'set')
9699
AND table_schema = ${this.schema()}
@@ -111,7 +114,12 @@ export class MySQL {
111114

112115
const tableColumns = await query<TableColumnType>(
113116
this.connection,
114-
sql`SELECT column_name, data_type, is_nullable, column_default, column_comment
117+
sql`SELECT
118+
column_name as column_name,
119+
data_type as data_type,
120+
is_nullable as is_nullable,
121+
column_default as column_default,
122+
column_comment as column_comment
115123
FROM information_schema.columns
116124
WHERE table_name = ${tableName}
117125
AND table_schema = ${tableSchema}`

0 commit comments

Comments
 (0)