diff --git a/server/szurubooru/func/tag_categories.py b/server/szurubooru/func/tag_categories.py index 64e6bec..e09ffb9 100644 --- a/server/szurubooru/func/tag_categories.py +++ b/server/szurubooru/func/tag_categories.py @@ -1,4 +1,5 @@ import re +import sqlalchemy from szurubooru import config, db, errors from szurubooru.func import util, snapshots, cache @@ -37,7 +38,7 @@ def create_category(name, color): def update_category_name(category, name): if not name: raise InvalidTagCategoryNameError('Name cannot be empty.') - expr = db.TagCategory.name.ilike(name) + expr = sqlalchemy.func.lower(db.TagCategory.name) == name.lower() if category.tag_category_id: expr = expr & (db.TagCategory.tag_category_id != category.tag_category_id) already_exists = db.session.query(db.TagCategory).filter(expr).count() > 0 @@ -61,7 +62,7 @@ def update_category_color(category, color): def try_get_category_by_name(name): return db.session \ .query(db.TagCategory) \ - .filter(db.TagCategory.name.ilike(name)) \ + .filter(sqlalchemy.func.lower(db.TagCategory.name) == name.lower()) \ .one_or_none() def get_category_by_name(name): diff --git a/server/szurubooru/func/tags.py b/server/szurubooru/func/tags.py index 057fa18..34d63c1 100644 --- a/server/szurubooru/func/tags.py +++ b/server/szurubooru/func/tags.py @@ -90,7 +90,7 @@ def try_get_tag_by_name(name): return db.session \ .query(db.Tag) \ .join(db.TagName) \ - .filter(db.TagName.name.ilike(name)) \ + .filter(sqlalchemy.func.lower(db.TagName.name) == name.lower()) \ .one_or_none() def get_tag_by_name(name): @@ -105,7 +105,7 @@ def get_tags_by_names(names): return [] expr = sqlalchemy.sql.false() for name in names: - expr = expr | db.TagName.name.ilike(name) + expr = expr | (sqlalchemy.func.lower(db.TagName.name) == name.lower()) return db.session.query(db.Tag).join(db.TagName).filter(expr).all() def get_or_create_tags_by_names(names): @@ -192,7 +192,7 @@ def update_tag_names(tag, names): for name in names: if util.value_exceeds_column_size(name, db.TagName.name): raise InvalidTagNameError('Name is too long.') - expr = expr | db.TagName.name.ilike(name) + expr = expr | (sqlalchemy.func.lower(db.TagName.name) == name.lower()) if tag.tag_id: expr = expr & (db.TagName.tag_id != tag.tag_id) existing_tags = db.session.query(db.TagName).filter(expr).all()