Browse Source

Allow negative comparison on null topics

Topics can be null, which means they can't be compared to strings.
So a query with "topic:foo" would match changes with topic foo,
and not match changes with topic bar or the null topic.  However,
the inverse, "not topic:foo" does not work as expected.  It would
match changes with topic bar, but *not* changes with the null topic
because that comparison evaluates to unknown.

By changing the predicate to "topic is not null and topic = foo"
we achive the same results on the positive query, and the negation
of that query works as well (since if the topic is null, the
expression will evaluate to false in the first half, and if the
topic is bar, evaluate to false in the second half).

Change-Id: I5a81d5eaae1ef43cea6b897d44a631cac00bf081
James E. Blair 2 years ago
parent
commit
2d2fb1509c
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      gertty/search/parser.py

+ 2
- 1
gertty/search/parser.py View File

@@ -199,7 +199,8 @@ def SearchParser():
199 199
         if p[2].startswith('^'):
200 200
             p[0] = func.matches(p[2], gertty.db.change_table.c.topic)
201 201
         else:
202
-            p[0] = gertty.db.change_table.c.topic == p[2]
202
+            p[0] = and_(gertty.db.change_table.c.topic.isnot(None),
203
+                        gertty.db.change_table.c.topic == p[2])
203 204
 
204 205
     def p_ref_term(p):
205 206
         '''ref_term : OP_REF string'''

Loading…
Cancel
Save