Issues with Component set to None don't appear in search

Andrew Pratt April 22, 2013

When a user was searching with the following filter, issues with no component values set did not appear in the search results. Any idea why?

project = XYZ AND component != "ABCDEF" AND status != Closed ORDER BY key DESC

where ABCDEF is a component in project XYZ.

By "no component values set", I mean the Component was blank or None.

2 answers

1 accepted

3 votes
Answer accepted
Paul Alexander
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2013

Andrew, I've always stacked to the get nulls returned; so,

project = XYZ AND component != "ABCDEF" AND status != Closed OR project = XYZ AND component is empty AND status != Closed ORDER BY key DESC

Andrew Pratt April 22, 2013

Perfect. I shortened it to the following:

project = ABC AND (component != "ABCDEF" or Component is empty) and status != Closed ORDER BY Key DESC

and this seems to work as well.

But I still don't understand entirely why we have to add the "Component is empty" part. Something to do with databases and nulls versus empty strings in a query?

Andrew Pratt April 22, 2013

Thanks. Appreciate the quick answer.

Paul Alexander
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2013

Yup, you must explicitly find nulls using the keyword, 'empty' or 'null'.

https://confluence.atlassian.com/display/AOD/Advanced+Searching#AdvancedSearching-EMPTY

Andrew Pratt April 22, 2013

But it doesn't really explain why the "!=" didn't work. Wouldn't null or empty be "!= ABCDEF"?

Paul Alexander
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2013

Oh I missed your question...that's the way a relational database works. Any comparison with null is always false. If a column can have a null value, to get nulls you need to explicitly include them.

Andrew Pratt April 22, 2013

Yes, I suspected that was what was lurking in the back ground. Thanks again for the solution and the answer to the "why".

3 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 22, 2013

It's not just because the database works that way, it's because the world works that way and a database reflects it.

Think of the question "what colour is your cat?". Possible answers might be tortoiseshell, ginger, black, and grey, so you can ask select questions like "show me all the cats that are not ginger". But "I don't have a cat" is also an answer, and one that should clearly not show up in a select question.

In logical terms, "null" is something different from "yes" or "no" and needs to be handled clearly and distinctly.

Andrew Pratt April 22, 2013

Thanks Nic. I love your clear example.

Of course, this means I can't blame data base programers any more. ;)

Suggest an answer

Log in or Sign up to answer