mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-17 00:08:55 +01:00
use asciiOnlyToLowerCase to match lower function behaviour of SQLite
This commit is contained in:
parent
def34a860b
commit
0af29a378a
@ -1,5 +1,6 @@
|
|||||||
const { DataTypes, Model, where, fn, col } = require('sequelize')
|
const { DataTypes, Model, where, fn, col } = require('sequelize')
|
||||||
const parseNameString = require('../utils/parsers/parseNameString')
|
const parseNameString = require('../utils/parsers/parseNameString')
|
||||||
|
const { asciiOnlyToLowerCase } = require('../utils/index')
|
||||||
|
|
||||||
class Author extends Model {
|
class Author extends Model {
|
||||||
constructor(values, options) {
|
constructor(values, options) {
|
||||||
@ -53,27 +54,15 @@ class Author extends Model {
|
|||||||
* @returns {Promise<Author>}
|
* @returns {Promise<Author>}
|
||||||
*/
|
*/
|
||||||
static async getByNameAndLibrary(authorName, libraryId) {
|
static async getByNameAndLibrary(authorName, 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({
|
return this.findOne({
|
||||||
where: [
|
where: [
|
||||||
where(fn('lower', col('name')), authorName.toLowerCase()),
|
where(fn('lower', col('name')), asciiOnlyToLowerCase(authorName)),
|
||||||
{
|
{
|
||||||
libraryId
|
libraryId
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const { DataTypes, Model, where, fn, col } = require('sequelize')
|
const { DataTypes, Model, where, fn, col } = require('sequelize')
|
||||||
|
|
||||||
const { getTitlePrefixAtEnd } = require('../utils/index')
|
const { getTitlePrefixAtEnd } = require('../utils/index')
|
||||||
|
const { asciiOnlyToLowerCase } = require('../utils/index')
|
||||||
|
|
||||||
class Series extends Model {
|
class Series extends Model {
|
||||||
constructor(values, options) {
|
constructor(values, options) {
|
||||||
@ -39,27 +40,15 @@ class Series extends Model {
|
|||||||
* @returns {Promise<Series>}
|
* @returns {Promise<Series>}
|
||||||
*/
|
*/
|
||||||
static async getByNameAndLibrary(seriesName, libraryId) {
|
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
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
return this.findOne({
|
return this.findOne({
|
||||||
where: [
|
where: [
|
||||||
where(fn('lower', col('name')), seriesName.toLowerCase()),
|
where(fn('lower', col('name')), asciiOnlyToLowerCase(seriesName)),
|
||||||
{
|
{
|
||||||
libraryId
|
libraryId
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize model
|
* Initialize model
|
||||||
|
Loading…
Reference in New Issue
Block a user