QueryParser Driver: Protect against NULLs
authorThomas Berezansky <tsbere@mvlc.org>
Tue, 11 Sep 2012 19:02:59 +0000 (15:02 -0400)
committerDan Scott <dscott@laurentian.ca>
Tue, 27 Nov 2012 18:52:34 +0000 (13:52 -0500)
commite5636ca382d42a826024ee45856c25b8c02120a9
tree1c4ea3e87616f75c6b9db58becdf3c97f78f9d1d
parentddb7f66a60d6fc97f3b491188fccca8b572b8516
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>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm