Ticket #16211: django-query-expression-negate.patch
File django-query-expression-negate.patch, 1.4 KB (added by , 13 years ago) |
---|
-
django/db/models/expressions.py
old new class ExpressionNode(tree.Node): 20 20 AND = '&' 21 21 OR = '|' 22 22 23 # Logical operators 24 NOT = 'NOT' # unary, needs special attention in combine_expression 25 23 26 def __init__(self, children=None, connector=None, negated=False): 24 27 if children is not None and len(children) > 1 and connector is None: 25 28 raise TypeError('You have to specify a connector.') … … class ExpressionNode(tree.Node): 48 51 # OPERATORS # 49 52 ############# 50 53 54 def __invert__(self): 55 obj = ExpressionNode([self], connector=self.NOT, negated=True) 56 return obj 57 51 58 def __add__(self, other): 52 59 return self._combine(other, self.ADD, False) 53 60 -
django/db/backends/__init__.py
old new class BaseDatabaseOperations(object): 472 472 can vary between backends (e.g., Oracle with %% and &) and between 473 473 subexpression types (e.g., date expressions) 474 474 """ 475 if connector == 'NOT': 476 assert len(sub_expressions) == 1 477 return 'NOT (%s)' % sub_expressions[0] 475 478 conn = ' %s ' % connector 476 479 return conn.join(sub_expressions) 477 480