server/search: permit search for tags by alias
This commit is contained in:
parent
6179f016ae
commit
172b956e48
|
@ -134,5 +134,5 @@ class BaseSearchConfig(object):
|
||||||
subquery = subquery.options(sqlalchemy.orm.lazyload('*'))
|
subquery = subquery.options(sqlalchemy.orm.lazyload('*'))
|
||||||
subquery = filter_func(subquery, criterion)
|
subquery = filter_func(subquery, criterion)
|
||||||
subquery = subquery.subquery('t')
|
subquery = subquery.subquery('t')
|
||||||
return query.filter(left_id_column == subquery.c.foreign_id)
|
return query.filter(left_id_column.in_(subquery))
|
||||||
return func
|
return func
|
||||||
|
|
|
@ -23,12 +23,20 @@ class TagSearchConfig(BaseSearchConfig):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def anonymous_filter(self):
|
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
|
@property
|
||||||
def named_filters(self):
|
def named_filters(self):
|
||||||
return util.unalias_dict({
|
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(
|
'category': self._create_subquery_filter(
|
||||||
db.Tag.category_id,
|
db.Tag.category_id,
|
||||||
db.TagCategory.tag_category_id,
|
db.TagCategory.tag_category_id,
|
||||||
|
|
|
@ -47,6 +47,7 @@ def test_filter_anonymous(verify_unpaged, tag_factory, input, expected_tag_names
|
||||||
('name:tag1,tag2', ['tag1', 'tag2']),
|
('name:tag1,tag2', ['tag1', 'tag2']),
|
||||||
('-name:tag1,tag3', ['tag2', 'tag4']),
|
('-name:tag1,tag3', ['tag2', 'tag4']),
|
||||||
('name:tag4', ['tag4']),
|
('name:tag4', ['tag4']),
|
||||||
|
('name:tag5', ['tag4']),
|
||||||
('name:tag4,tag5', ['tag4']),
|
('name:tag4,tag5', ['tag4']),
|
||||||
])
|
])
|
||||||
def test_filter_by_name(verify_unpaged, tag_factory, input, expected_tag_names):
|
def test_filter_by_name(verify_unpaged, tag_factory, input, expected_tag_names):
|
||||||
|
|
Loading…
Reference in New Issue