silverstripe/silverstripe-framework — pull request #3436 by wilr (2014-08-26 03:00:21+00:00)
Title: FIX: Sorting a DataQuery over a relation.

When sorting a DataQuery over a relation, the SQLQuery automatically included the sort column. The issue with the implement is that potentially the joined record has a field with the same name as the source record causing it to be overridden.

In the attached test case, without the patch the title will be set to 'Bar' rather than 'Foo'.

This patch aliases the sort column similar to what we do currently. Alternatively aliasing to {TableName_Field} might be more user friendly if users expect to use the sort column (though this is a DataQuery)