Changes between Initial Version and Version 1 of Ticket #34978, comment 4
- Timestamp:
- Nov 20, 2023, 9:26:03 AM (13 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #34978, comment 4
initial v1 43 43 > This one's interesting because we can't dig into RawSQL to determine whether it's valid in a GROUP BY or not. 44 44 45 That's right David, it's the crux of the issue. 45 That's right David, it's the crux of the issue. Since it's a blackbox the ORM must choose between grouping or not by the column and since most `RawSQL` usage are assumed to not be aggregation it determines that it must do so. 46 46 47 47 The reason why 041551d716b69ee7c81199eee86a2d10a72e15ab broke the reported use that is that prior to this change the ORM supported a non-standard feature of MySQL [https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html disabled in recent versions] that allowed grouping solely by the primary key of the first entry in `FROM`. It's important to note that using `RawSQL` to aggregate was only working on MySQL due to this feature and never worked on any of the other backends that follow the functional dependency detection in `GROUP BY` clauses as specified by the `SQL:1999` standard. … … 53 53 1. Revert the changes made in 041551d716b69ee7c81199eee86a2d10a72e15ab while making `allows_group_by_pk` based on the absence of `ONLY_FULL_GROUP_BY`. Note that this won't resolve the aggregation over the annotation of a dependant subquery but will restore the usage of `RawSQL` for aggregation on MySQL only when `ONLY_FULL_GROUP_BY` is disabled. 54 54 2. 1 + adjustments to the `allows_group_by_pk` to special case dependant subquery annotations 55 3. Adjust the 4.2 existing release notes about this change to let them knowthat this version of Django removed support for doing `RawSQL` aggregations on MySQL and that they should use proper expressions instead going forward.55 3. Adjust the 4.2 existing release notes about this change to better communicate that this version of Django removed support for doing `RawSQL` aggregations on MySQL and that they should use proper expressions instead going forward. 56 56 57 57 Due to lack of demonstration that some aggregates or window function cannot be expressed using the advanced ORM primitives, that non-`ONLY_FULL_GROUP_BY` model is a non standard MySQL feature that is not enabled by default since 8.0, and that this change happen to standardize the usage of `RawSQL` for aggregations on all backends I'd be inclined to go with 3.