QueryParser Driver: Protect against NULLs
authorThomas Berezansky <tsbere@mvlc.org>
Tue, 11 Sep 2012 19:02:59 +0000 (15:02 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Tue, 11 Sep 2012 19:39:26 +0000 (15:39 -0400)
commit91ace013a2dd3069bab3f4965ae6e89a9122f484
tree46c116247f7cc69753a317854f4afdc73b71e25e
parentc5cd070ecbad163bd72bbe03a50a4547c9fff6c2
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