From 2d2fb1509c1e08b1782df1908de23691e139097b Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 17 Mar 2017 14:43:47 -0700 Subject: [PATCH] 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 --- gertty/search/parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gertty/search/parser.py b/gertty/search/parser.py index f1cd295..8b5d6a1 100644 --- a/gertty/search/parser.py +++ b/gertty/search/parser.py @@ -199,7 +199,8 @@ def SearchParser(): if p[2].startswith('^'): p[0] = func.matches(p[2], gertty.db.change_table.c.topic) else: - p[0] = gertty.db.change_table.c.topic == p[2] + p[0] = and_(gertty.db.change_table.c.topic.isnot(None), + gertty.db.change_table.c.topic == p[2]) def p_ref_term(p): '''ref_term : OP_REF string'''