mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-02 09:14:40 +02:00
use asciiOnlyToLowerCase to match lower function behaviour of SQLite
This commit is contained in:
parent
def34a860b
commit
0af29a378a
2 changed files with 16 additions and 38 deletions
|
@ -1,6 +1,7 @@
|
|||
const { DataTypes, Model, where, fn, col } = require('sequelize')
|
||||
|
||||
const { getTitlePrefixAtEnd } = require('../utils/index')
|
||||
const { asciiOnlyToLowerCase } = require('../utils/index')
|
||||
|
||||
class Series extends Model {
|
||||
constructor(values, options) {
|
||||
|
@ -39,26 +40,14 @@ class Series extends Model {
|
|||
* @returns {Promise<Series>}
|
||||
*/
|
||||
static async getByNameAndLibrary(seriesName, 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
|
||||
return this.findOne({
|
||||
where: [
|
||||
where(fn('lower', col('name')), asciiOnlyToLowerCase(seriesName)),
|
||||
{
|
||||
libraryId
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return this.findOne({
|
||||
where: [
|
||||
where(fn('lower', col('name')), seriesName.toLowerCase()),
|
||||
{
|
||||
libraryId
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue