mirror of https://github.com/zulip/zulip.git
Support has:* searches on the back end.
(imported from commit a6a6f465ce0343d4a5313ee54f6ff427940a03ab)
This commit is contained in:
parent
25a9eae74b
commit
82a935080d
|
@ -96,6 +96,15 @@ class NarrowBuilderTest(AuthedTestCase):
|
|||
term = dict(operator='search', operand='"french fries"')
|
||||
check(term, 'WHERE (lower(content) LIKE lower(:content_1) OR lower(subject) LIKE lower(:subject_1)) AND (search_tsvector @@ plainto_tsquery(:param_2, :param_3))')
|
||||
|
||||
term = dict(operator='has', operand='attachment')
|
||||
check(term, 'WHERE has_attachment')
|
||||
|
||||
term = dict(operator='has', operand='image')
|
||||
check(term, 'WHERE has_image')
|
||||
|
||||
term = dict(operator='has', operand='link')
|
||||
check(term, 'WHERE has_link')
|
||||
|
||||
class IncludeHistoryTest(AuthedTestCase):
|
||||
def test_ok_to_include_history(self):
|
||||
realm = get_realm('zulip.com')
|
||||
|
|
|
@ -111,6 +111,13 @@ class NarrowBuilder(object):
|
|||
|
||||
return method(query, operand, maybe_negate)
|
||||
|
||||
def by_has(self, query, operand, maybe_negate):
|
||||
if operand not in ['attachment', 'image', 'link']:
|
||||
raise BadNarrowOperator("unknown 'has' operand " + operand)
|
||||
col_name = 'has_' + operand
|
||||
cond = column(col_name)
|
||||
return query.where(maybe_negate(cond))
|
||||
|
||||
def by_is(self, query, operand, maybe_negate):
|
||||
if operand == 'private':
|
||||
query = query.select_from(join(query.froms[0], "zerver_recipient",
|
||||
|
|
Loading…
Reference in New Issue