From e2f484911ea86e0a055dc8bd31c1133f6c5785bf Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 6 Apr 2009 12:44:31 +0000 Subject: [PATCH] fix corner case like ~slice_id:[] --- PLC/Filter.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/PLC/Filter.py b/PLC/Filter.py index ba50d21..c90f713 100644 --- a/PLC/Filter.py +++ b/PLC/Filter.py @@ -120,13 +120,18 @@ class Filter(Parameter, dict): raise PLCInvalidArgument, "Invalid filter field '%s'" % field if isinstance(value, (list, tuple, set)): - # Turn empty list into (NULL) instead of invalid () + # handling filters like '~slice_id':[] + # this should return true, as it's the opposite of 'slice_id':[] which is false + # prior to this fix, 'slice_id':[] would have returned ``slice_id IN (NULL) '' which is unknown + # so it worked by coincidence, but the negation '~slice_ids':[] would return false too if not value: - value = [None] - - operator = "IN" - value = map(str, map(api.db.quote, value)) - value = "(%s)" % ", ".join(value) + field="" + operator="" + value = "FALSE" + else: + operator = "IN" + value = map(str, map(api.db.quote, value)) + value = "(%s)" % ", ".join(value) else: if value is None: operator = "IS" -- 2.43.0