diff --git a/server/szurubooru/search/base_search_config.py b/server/szurubooru/search/base_search_config.py index 9f97973c..f07f2044 100644 --- a/server/szurubooru/search/base_search_config.py +++ b/server/szurubooru/search/base_search_config.py @@ -134,5 +134,5 @@ class BaseSearchConfig(object): subquery = subquery.options(sqlalchemy.orm.lazyload('*')) subquery = filter_func(subquery, criterion) subquery = subquery.subquery('t') - return query.filter(left_id_column == subquery.c.foreign_id) + return query.filter(left_id_column.in_(subquery)) return func diff --git a/server/szurubooru/search/tag_search_config.py b/server/szurubooru/search/tag_search_config.py index bea17f2e..689bba7e 100644 --- a/server/szurubooru/search/tag_search_config.py +++ b/server/szurubooru/search/tag_search_config.py @@ -23,12 +23,20 @@ class TagSearchConfig(BaseSearchConfig): @property def anonymous_filter(self): - return self._create_str_filter(db.Tag.first_name) + return self._create_subquery_filter( + db.Tag.tag_id, + db.TagName.tag_id, + db.TagName.name, + self._create_str_filter) @property def named_filters(self): return util.unalias_dict({ - 'name': self._create_str_filter(db.Tag.first_name), + 'name': self._create_subquery_filter( + db.Tag.tag_id, + db.TagName.tag_id, + db.TagName.name, + self._create_str_filter), 'category': self._create_subquery_filter( db.Tag.category_id, db.TagCategory.tag_category_id, diff --git a/server/szurubooru/tests/search/test_tag_search_config.py b/server/szurubooru/tests/search/test_tag_search_config.py index 2e834fc8..3b234337 100644 --- a/server/szurubooru/tests/search/test_tag_search_config.py +++ b/server/szurubooru/tests/search/test_tag_search_config.py @@ -47,6 +47,7 @@ def test_filter_anonymous(verify_unpaged, tag_factory, input, expected_tag_names ('name:tag1,tag2', ['tag1', 'tag2']), ('-name:tag1,tag3', ['tag2', 'tag4']), ('name:tag4', ['tag4']), + ('name:tag5', ['tag4']), ('name:tag4,tag5', ['tag4']), ]) def test_filter_by_name(verify_unpaged, tag_factory, input, expected_tag_names):