#34262: Queryset grouped by annotation with aggregates on another annotated
expression crashes on MySQL with sql_mode=only_full_group_by.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: ontowhee
Type: Bug | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: mysql | Triage Stage: Accepted
only_full_group_by |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* has_patch: 0 => 1
* needs_better_patch: 0 => 1
Comment:
I left some comments on the PR but this is looking promising. I provided a
way to make it work for SQLite as well.
> Question: Is this a good approach? Or should AnyValue() implement over
clause?
Given SQLite doesn't support it and the `FirstValue` window-compatible
function I think it might be better to set `window_compatible = False` on
it for now and revisit in the future if truly needed.
> The filter clause is leveraging the existing filter implementation for
expressions. For MySQL, this means it creates CASE() instead of FILTER().
That's expected just like with any other aggregates. Is this causing
issues with `NULL` values generated by members that should be filtered
out?
> The chart in the article shows a lightning bolt MySQL. I may be
misunderstanding what that means, but I have not been able to directly run
a “ANY_VALUE() FILTER() OVER()” expression. I tried to keep the scope of
this ticket simple by not addressing this one for now.
The issue goes away if we don't initially support its usage in window
functions which I think is okay for now.
> This avoids the error that is raised Cannot compute ... is an aggregate
error in resolve_expression, and it seems to make sense now that all the
columns have an "aggregate" function operating on them.
That makes sense to me as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/34262#comment:18>
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 visit
https://groups.google.com/d/msgid/django-updates/010701959b8c3cde-131b7644-cb7e-4098-a10e-f81cf88717e2-000000%40eu-central-1.amazonses.com.