Skip to content

Commit 55baefe

Browse files
committed
fix: crash if no tables in database
1 parent eea3d1a commit 55baefe

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/parser/mysql.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ async function getTableNames(
3636
): Promise<string[]> {
3737
const query = await knex.raw(`show tables from \`${databaseName}\``);
3838
const [res] = await query;
39+
if (!res) {
40+
console.warn(`no tables in database ${databaseName}`);
41+
return [];
42+
}
43+
3944
const key = Object.keys(res[0])[0];
4045
return res.map((r: any) => r[key]);
4146
}

0 commit comments

Comments
 (0)