#34978: Annotating through an aggregate with RawSQL() raises 1056 "Can't group
on"
on MySQL/MariaDB.
-------------------------------------+-------------------------------------
Reporter: Matthew Somerville | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Release blocker | 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 Matthew Somerville):
Given the same query does already use `Min()`, as quoted, I am at a loss
as to why I wasn't using it in the other part! Thanks for the
investigation; an addition to the 4.2 release notes explaining the change
further (I did read those, but only saw the reference to changes in
"third-party database backends") would be welcome, thank you.
With the change to your first option¹, my code passes on Django 4.2 fine
with `ONLY_FULL_GROUP_BY` turned off, thank you; turning that option on I
get a lot of 1055 errors, even with a query that's only e.g.
`Play.objects.annotate(Count('authors'))`, without any RawSQL, I get
`(1055, "'theatricalia.plays_play.title' isn't in GROUP BY")`, but assume
that's my issue somehow.
¹ If you're interested, regarding your second/third code change options,
press_date is a DateField but start_date/end_date are
ApproximateDateFields from my https://pypi.org/project/django-date-
extensions/ so that becomes a bit more complex.
--
Ticket URL: <https://code.djangoproject.com/ticket/34978#comment:6>
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/0107018bedf49b15-e93d4778-c3da-432d-ba83-d4e317590783-000000%40eu-central-1.amazonses.com.