Ticket #17186: invert.f.patch
File invert.f.patch, 1.1 KB (added by , 13 years ago) |
---|
-
db/models/expressions.py
98 98 """ 99 99 An expression representing the value of the given field. 100 100 """ 101 102 self._invert = False 103 101 104 def __init__(self, name): 102 105 super(F, self).__init__(None, None, False) 103 106 self.name = name … … 107 110 obj.name = self.name 108 111 return obj 109 112 113 def __invert__(self): 114 self._invert = True 115 return self 116 110 117 def prepare(self, evaluator, query, allow_joins): 111 118 return evaluator.prepare_leaf(self, query, allow_joins) 112 119 113 120 def evaluate(self, evaluator, qn, connection): 114 return evaluator.evaluate_leaf(self, qn, connection) 121 evresult = list(evaluator.evaluate_leaf(self, qn, connection)) 122 if self._invert: 123 evresult[0] = "NOT %s" % evresult[0] 124 return tuple(evresult) 115 125 126 116 127 class DateModifierNode(ExpressionNode): 117 128 """ 118 129 Node that implements the following syntax: