Skip to content

Commit

Permalink
fix: crash if no tables in database
Browse files Browse the repository at this point in the history
  • Loading branch information
wirekang committed Sep 9, 2022
1 parent eea3d1a commit 55baefe
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/parser/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ async function getTableNames(
): Promise<string[]> {
const query = await knex.raw(`show tables from \`${databaseName}\``);
const [res] = await query;
if (!res) {
console.warn(`no tables in database ${databaseName}`);
return [];
}

const key = Object.keys(res[0])[0];
return res.map((r: any) => r[key]);
}
Expand Down

0 comments on commit 55baefe

Please sign in to comment.