From 7abe61ddbeb47ced44f58073bb1a9af5a7adc31c Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 21 Nov 2006 10:22:05 +0000 Subject: [PATCH] support for negation with fields starting with ~ --- PLC/Filter.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PLC/Filter.py b/PLC/Filter.py index a7c14ce5..139da580 100644 --- a/PLC/Filter.py +++ b/PLC/Filter.py @@ -53,6 +53,12 @@ class Filter(Parameter, dict): assert join_with in ("AND", "OR") for field, value in self.iteritems(): + # provide for negation with a field starting with ~ + negation=False + if field[0]=='~': + negation=True + field=field[1:] + if field not in self.fields: raise PLCInvalidArgument, "Invalid filter field '%s'" % field @@ -72,6 +78,10 @@ class Filter(Parameter, dict): operator = "=" value = str(api.db.quote(value)) - conditionals.append("%s %s %s" % (field, operator, value)) + clause = "%s %s %s" % (field, operator, value) + if negation: + clause = " ( NOT %s ) "%clause + + conditionals.append(clause) return (" %s " % join_with).join(conditionals) -- 2.47.0