Fix:Duplicate series and authors being added on matches and scans #2106

This commit is contained in:
advplyr 2023-09-17 15:29:39 -05:00
parent 0aae672e19
commit d18592eaeb
3 changed files with 16 additions and 14 deletions

View file

@ -1,4 +1,4 @@
const { DataTypes, Model, literal } = require('sequelize')
const { DataTypes, Model, where, fn, col } = require('sequelize')
const oldAuthor = require('../objects/entities/Author')
@ -114,14 +114,11 @@ class Author extends Model {
static async getOldByNameAndLibrary(authorName, libraryId) {
const author = (await this.findOne({
where: [
literal(`name = ':authorName' COLLATE NOCASE`),
where(fn('lower', col('name')), authorName.toLowerCase()),
{
libraryId
}
],
replacements: {
authorName
}
]
}))?.getOldAuthor()
return author
}