-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
4.3
-
Microsoft SQL, Oracle
-
MOODLE_403_STABLE
We currently can only GROUP BY <column_alias> on MySQL & Postgres (reference)
The reason we want to support this is for report columns that have parameters, because we end up re-using the same SQL (with identical parameters) in the GROUP BY clause which causes DML errors due to mismatched params/counts. e.g.
// Oracle/SQL Server
|
SELECT :foo AS alias, SUM(bar) |
FROM ... WHERE ... |
GROUP BY :foo; |
|
['foo' => 42] |
|
// MySQL/Postgres
|
SELECT :foo AS alias, SUM(bar) |
FROM ... WHERE ... |
GROUP BY alias; |
|
['foo' => 42] |
It's easy to workaround this limitation, just by calling ->set_groupby_sql(...) on the column, but it's nice to not have to remember to do that just because of Oracle & SQL Server
Oracle 23c has this feature coming soon, see also this video - at the point at which this is the minimum requirement for Moodle, we should update the code referenced above
SQL Server still does not have this feature, nor does it appear is it on the horizon. Let's keep an eye out for possible solutions
- has been marked as being related by
-
MDL-78784 Database engine consistency with DISTINCT group concat in report aggregation
-
- Open
-