Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 25043c8

Browse files
committed
null-check genre store
Signed-off-by: Sahil Gupte <[email protected]>
1 parent d7db5f1 commit 25043c8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/utils/main/db/database.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,12 +644,14 @@ export class SongDBInstance extends DBUtils {
644644
const genreID: string[] = []
645645
if (genre) {
646646
for (const a of genre) {
647-
const id = this.db.queryFirstCell(`SELECT genre_id FROM genre WHERE genre_name = ? COLLATE NOCASE`, a)
648-
if (id) genreID.push(id)
649-
else {
650-
const id = v4()
651-
this.db.insert('genre', { genre_id: id, genre_name: a.trim() })
652-
genreID.push(id)
647+
if (a) {
648+
const id = this.db.queryFirstCell(`SELECT genre_id FROM genre WHERE genre_name = ? COLLATE NOCASE`, a)
649+
if (id) genreID.push(id)
650+
else {
651+
const id = v4()
652+
this.db.insert('genre', { genre_id: id, genre_name: a.trim() })
653+
genreID.push(id)
654+
}
653655
}
654656
}
655657
}

0 commit comments

Comments
 (0)