Skip to content

Commit

Permalink
Rename selected columns to guarantee correct case (#7)
Browse files Browse the repository at this point in the history
Fixes a column-name issue that seems to affect mysql@8

See description/info here: SweetIQ/schemats#97
  • Loading branch information
maranomynet authored Feb 20, 2021
1 parent 711b641 commit 2b31804
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/mysql-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class MySQL {
private async tableNames(): Promise<string[]> {
const schemaTables = await query<TableType>(
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
Expand All @@ -90,7 +90,10 @@ export class MySQL {

const rawEnumRecords = await query<EnumRecord>(
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()}
Expand All @@ -111,7 +114,12 @@ export class MySQL {

const tableColumns = await query<TableColumnType>(
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}`
Expand Down

0 comments on commit 2b31804

Please sign in to comment.