#16211: using negated F()-expression in update query
-------------------------------------+-------------------------------------
Reporter: Walter Doekes | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
If anyone is interested in implementing this feature now that the
landscape has change quite a bit with the introduction of `Expression` I'd
suggest doing the following.
- Introduce a `NegatedExpression(ExpressionWrapper)` class that
`Combinable.__invert__(self)` returns as `NegatedExpression(self)`
- `NegatedExpression.as_sql` should return `sql = "NOT
{super().as_sql(...)}`
- `NegatedExpression.__invert__` should return `self.expression`
- `NegatedExpression.output_field` should be `BooleanField`
- Possibly have `Expression.__invert__` error out `if not
self.conditional`?
- Remove the custom `Exists.__invert__`
- Add tests for the whole thing
All the other usage cases mentioned in this ticket seem to already be
covered by `Combinable` additions in the past years.
--
Ticket URL: <https://code.djangoproject.com/ticket/16211#comment:45>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070182a4780a8d-84b78cc9-5b4f-410e-b0be-760601bc35ba-000000%40eu-central-1.amazonses.com.