diff --git a/server/models/Author.js b/server/models/Author.js index f3bbba57..7115a85e 100644 --- a/server/models/Author.js +++ b/server/models/Author.js @@ -53,14 +53,26 @@ class Author extends Model { * @returns {Promise} */ static async getByNameAndLibrary(authorName, libraryId) { - return this.findOne({ - where: [ - where(fn('lower', col('name')), authorName.toLowerCase()), - { - libraryId + const containsOnlyASCII = /^[\u0000-\u007f]*$/.test(authorName) + + // SQLite does not support lower with non-Unicode chars + if (!containsOnlyASCII) { + return this.findOne({ + where: { + name: authorName, + libraryId: libraryId } - ] - }) + }) + } else { + return this.findOne({ + where: [ + where(fn('lower', col('name')), authorName.toLowerCase()), + { + libraryId + } + ] + }) + } } /** diff --git a/server/models/Series.js b/server/models/Series.js index c57a1a11..9eab76b9 100644 --- a/server/models/Series.js +++ b/server/models/Series.js @@ -39,14 +39,26 @@ class Series extends Model { * @returns {Promise} */ static async getByNameAndLibrary(seriesName, libraryId) { - return this.findOne({ - where: [ - where(fn('lower', col('name')), seriesName.toLowerCase()), - { - libraryId + const containsOnlyASCII = /^[\u0000-\u007f]*$/.test(authorName) + + // SQLite does not support lower with non-Unicode chars + if (!containsOnlyASCII) { + return this.findOne({ + where: { + name: seriesName, + libraryId: libraryId } - ] - }) + }) + } else { + return this.findOne({ + where: [ + where(fn('lower', col('name')), seriesName.toLowerCase()), + { + libraryId + } + ] + }) + } } /**