#31917: MySQL Operational Error: "Unknown column 'x' in 'having clause'"
-------------------------------------+-------------------------------------
Reporter: StefanosChaliasos | Owner: nobody
Type: Uncategorized | Status: closed
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):
* status: new => closed
* resolution: => invalid
* component: Uncategorized => Database layer (models, ORM)
Comment:
IMO it's an issue in MySQL not in Django itself, see
[https://bugs.mysql.com/bug.php?id=78395 Bug #78395]. Expression is
included in the `GROUP BY` clause so it should work properly according to
MySQL docs:
> The SQL standard requires that HAVING must reference only columns in the
GROUP BY clause or columns used in aggregate functions.
As a workaround you can add `f1` to the selected columns `.values('f1',
'expr')`.
--
Ticket URL: <https://code.djangoproject.com/ticket/31917#comment:1>
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/075.26107b531b1b1693f0adc2a82d741851%40djangoproject.com.