mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
95bb799e6f
DataQuery::initialiseQuery() will add a default sort to a query, and when calling up an aggregate it will make a query like this which doesn't make sense: SELECT MAX("LastEdited") FROM "Member" ORDER BY "ID" In this case there is no need to add the ORDER BY, and it will break databases like MSSQL in cases such as GenericTemplateGlobalProvider which provides a default List() function for adding aggregates into SSViewer template cacheblocks. If we add a limit, however, then it does make sense: SELECT MAX("LastEdited") FROM "Member" ORDER BY "ID" LIMIT 10 This fixes SQLQuery::aggregate() to NOT add an ORDER BY to an aggregate call if there is no limit.