Commit eaa7a0a3 authored by Andrew Shu's avatar Andrew Shu

Include "inner" subpath tags when tag filtering

parent bac168bb
......@@ -147,7 +147,7 @@ class ArrayOfLtree(ARRAY):
if isinstance(other, list):
return self.op("?")(cast(other, ARRAY(LQUERY)))
else:
return self.op("~")(other)
return self.op("~")(cast(other, LQUERY))
class RecurrenceRule(TypeDecorator):
......
......@@ -206,13 +206,13 @@ class TopicQuery(PaginatedQuery):
def has_tag(self, tag: str) -> "TopicQuery":
"""Restrict the topics to ones with a specific tag (generative).
Note that this method searches for topics that have any tag that either starts
or ends with the specified tag, not only exact/full matches.
Note that this method searches for topics that have any tag that contains
the specified tag as a subpath, not only exact/full matches.
"""
queries = [f"{tag}.*", f"*.{tag}"]
query = f"*.{tag}.*"
# pylint: disable=protected-access
return self.filter(Topic.tags.lquery(queries)) # type: ignore
return self.filter(Topic.tags.lquery(query)) # type: ignore
def search(self, query: str) -> "TopicQuery":
"""Restrict the topics to ones that match a search query (generative)."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment