#17186: Inverted F expression (negation) -------------------------------------+------------------------------------- Reporter: niwi | Owner: nobody Type: New feature | Status: new Component: Database layer | Version: SVN (models, ORM) | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: | Needs documentation: 0 Has patch: 1 | Patch needs improvement: 0 Needs tests: 0 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by nate_b): There are several problems with this patch. For example, you should be able to negate compound expressions: {{{#!python >>> Demo.objects.filter(a_field=~(F('a_field')+1)) Traceback (most recent call last): File "<console>", line 1, in <module> TypeError: bad operand type for unary ~: 'ExpressionNode' }}} Secondly, there is no indication of negation in the string representation, like there is for other operators: {{{#!python >>> print ~F('field') (DEFAULT: ) >>> print F('field') + F('other') (+: (DEFAULT: ), (DEFAULT: )) }}} Thirdly, {{{tree.Node}}} already supplies a {{{negate()}}} function and a {{{negated}}} field. Why not use those instead? I'm not entirely pleased with my alternative as it still doesn't make use of {{{connector}}}, but it solves these listed problems. -- Ticket URL: <https://code.djangoproject.com/ticket/17186#comment:4> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.