QueryParser Driver: Protect against NULLs
authorThomas Berezansky <tsbere@mvlc.org>
Tue, 11 Sep 2012 19:02:59 +0000 (15:02 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 30 Jan 2013 16:29:27 +0000 (11:29 -0500)
commit682a4b1332392df915023a4d10e68a3430f901cb
tree1ee8653ee8c21c88394d6326f93f7dc49cc32e53
parent4128fbc1908df3d011f764260bfb2a8315d79e06
QueryParser Driver: Protect against NULLs

mrd.attrs->'value' can return NULL. If this happens:

Checking that the value is within a range or list will work fine.
NEGATING that will not.

This is because:
AND NULL returns NULL
AND NOT (NULL) also returns NULL

The solution? Adjust things so we can wrap all the offending checks in a
COALESCE to false. Then if mrd.attrs->'value' is null we get a false.

In the process we move any and all negations to outside the COALESCE.

Also apply the same logic to the bib_source filter, not to mention
making it support being negated.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm