1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

SQL ?传递array要考虑数组为空情况

This commit is contained in:
程序员小墨 2022-10-20 22:31:13 +08:00
parent 4f3aa180a0
commit 9a8565a1e3
2 changed files with 2 additions and 2 deletions

View File

@ -159,7 +159,7 @@ async function fetch({ albumId, debug = false, update = false }) {
songIds: songIds,
};
// console.log("albumInfo", albumInfo);
if (albumId > 0) {
if (albumId > 0 && songIds.length > 0) {
await dbUtils.query(`
INSERT IGNORE INTO song_album_relation (song_id, album_id) VALUES ?
`, [songIds.map(songId => [Number(songId), albumId])]);

View File

@ -110,7 +110,7 @@ async function fetch({ artistId, debug = false }) {
songIds: songIds,
};
// console.log("artistInfo", artistInfo);
if (artistId > 0) {
if (artistId > 0 && songIds.length > 0) {
await dbUtils.query(`
INSERT IGNORE INTO song_artist_relation (song_id, artist_id) VALUES ?
`, [songIds.map(songId => [Number(songId), artistId])]);