server/search: permit search for tags by alias

This commit is contained in:
rr- 2016-05-11 22:07:52 +02:00
parent 6179f016ae
commit 172b956e48
3 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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,

View File

@ -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):